Heyho!
I need to make some lines with gnuplot. However due to the small size of the plots, I want to make those lines fat. However they overlap now with the axis. and into the normal picture. How can I cut those lines of so they dont do it?
Thanks!
If you are plotting data, you can adjust the overall x and y ranges so that the lines don't overlap with the borders:
set xrange [xmin:xmax]
set yrange [ymin:ymax]
If you are plotting functions, you can also cut off lines by adjusting the range when you plot:
plot [xmin:xmax][ymin:ymax] ...
This is a little more tricky because the function will automatically go to the edge of the plot anyway. If this is the case, you can specify a larger range for a blank line:
plot [-2:2][-2:2] NaN notitle, [-1:1] x**2 title 'x^2'
Related
Contour lines generated by gnuplot can look pretty strange (unexpected) if you do not set both samples and isosamples to appropriate values. I struggled for hours to find out how exactly set samples and set isosamples affect the appearance of contour lines, however, all I observed is that setting both to sufficiently large values will generate good-looking contours. Still, I want to understand how exactly this works.
What is the difference between set samples and set isosamples in the context of contour lines?
How does set samples affect the generation of contour lines?
How does set isosamples affect the generation of contour lines?
For example, consider the following simple case:
unset surface
set contour
set cntrparam levels discrete 10, 20
set samples 250, 2
set isosamples 2, 250
set view map
splot x**2 + y**2
To generate correct contour lines, it appears you need to set the first parameter of samples and the second parameter of isosamples to sufficiently large values. However, setting the second parameter of samples and the first parameter of isosamples to the smallest possible value does no harm. This is not exactly intuitive. So how does this work?
First, a discussion on what samples and isosamples where designed to do. This is best when viewing the actual plot and not the contour map.
samples is used to set the number of function evaluations along an axis in the range being plotted. For splot (3-D images), you can control samples in both independent directions x and y. Here is a sample where the x-direction only has 4 evaluations and the y-direction has 200:
reset
set xrange [-10:10]
set yrange [-10:10]
set xlabel 'X'
set ylabel 'Y'
set samples 4,200
splot x**2+y**2
In the following 2 images note that along the x-direction, the function is only evaluated 4 times and straight lines are drawn between them. Along the y-direction, it is evaluated 200 times and it looks like 'smooth' curves. Note that in both directions, exactly 10 lines are drawn. I will get to that below while discussing isolines.
Looking toward x-axis:
Looking toward y-axis:
So, 10 lines in each axis direction are drawn because the default value for isolines in both x and y directions is 10. We can change this at will. Lets increase samples in both directions for a nice smooth curves but demonstrate isosamples.
reset
set xrange [-10:10]
set yrange [-10:10]
set xlabel 'X'
set ylabel 'Y'
set samples 200,200
set isosamples 4,12
splot x**2+y**2
Note the nice smooth curves in both directions. Along the x-axis, there are only 4 points where, along the y-axis, the surface curves are drawn and along the y-axis, there are 12 points where surface curves are drawn parallel to the x-axis.
The above examples demonstrate the primary purpose of set samples and set isosamples. They only indirectly affect contours. In your case, you are only interested in the contour map without even displaying the surface plot. A clue as to how gnuplot plots contours is in its explanation of how contours can be drawn with discreet data.
Gromacs:
In order to draw contours, the data should be organized as "grid data". In
such a file all the points for a single y-isoline are listed, then all the
points for the next y-isoline, and so on. A single blank line (a line
containing no characters other than blank spaces and a carriage return and/or
a line feed) separates one y-isoline from the next.
From this explanation, gnuplot seems to prefer to pick an x value and draw a y-isoline. We can deduce then that when gnuplot draws contours from functions, that it picks x values and draws y-isolines. Therefore having many x samples and many y isolines draws hi resolution contours while the y samples and the x isolines are irrelevant (if you are not drawing the surface).
So, here I am trying to plot heatmaps in gnuplot. I have a matrix-formatted text file (with row and column headers), and the command I am using to plot it is
plot "file.txt" matrix rowheaders columnheaders using 1:2:3 w image notitle
The output is this graph:
Obviously, the X and Y labels are useless like this. I believe the problem here is that gnuplot is extracting all labels from the file and plotting them. How would I go about reducing the amount of clutter in here, e.g. plotting every 10th label or so?
Thanks in advance.
Or just make the picture resolution bigger... for instance like 1920,1080 or bigger... like this:
set term pngcairo size 1920,1080
or make the tics numbers like 1000000 smaller and make a label to show that the numbers written on the tics are 1000000 bigger... or both:)
Sorry for my english...
I have to create a video presenting the evolution of some quantities as functions of time. I am creating images with gnuplot and I assemble them to make a movie. I am getting trouble generating the two first images: the first image is supposed to have no point on it (it is supposed to show only the title of the graph, the x and y axes and the labels of the axes) and the second one is supposed to have one single point on it.
Is it possible to create a graph containing no data on it with gnuplot?
Is it possible to create a graph containing one single point with gnuplot using an input file? The input file contains:
0 15
Thank you in advance for your answers,
Julien
To plot an empty graph, just plot a completely undefined function like
plot NaN
The main issue here is, that the autoscaling fails since there are no valid points. You must give a fixed xrange and yrange to get a plot:
set xrange [0:1]
set yrange [0:1]
plot NaN notitle
Plotting a single point works fine using
plot 'file.dat' using 1:2 with points
You'll get warnings saying Warning: empty x range [0:0], adjusting to [-1:1] and Warning: empty y range [15:15], adjusting to [14.85:15.15], but you get a plot. To remove the warnings, you must again provide a fixed xrange and yrange.
I have temperature data from eight different nonequidistant depths over several days and I would like to plot it as heatmap. As far as I know I have two options. I can use "with image" but that assumes equidistant points so that makes just 8 pixel thin strip or I can use pm3d which need proper grid(I am not sure what proper grid is). I found that dgrid3d can make the grid for me but that erases any dependency on depth for some reason. Can someone please explain this behavior to me?
Here is the code and the data I use.
https://docs.google.com/file/d/0B2TfUgjtGRVReV9ocFVvM1BKd2M
set timefmt "%Y-%m-%d %H:%M:%S"
set xdata time
set view map
set dgrid3d
splot './Data/MO-03t_.txt' every ::2 u 1:3:4 with pm3d
the dgrid3d does not plot your data. Instead, something like two-dimensional splines are calculated from your data. Then, gnuplot creates a (by default) 10x10 matrix, and fills it with values interpolated from the splines. This matrix is then plotted.
But I have an other solution for you:
set timefmt "%Y-%m-%d %H:%M:%S"
set xdata time
# for the nice colors
set pm3d
# For debugging: place ticmarks only vor values with data
set ytics (0.02, 0.04, 0.06, 0.11, 0.31, 0.41, 0.61, 0.91)
plot './Data/MO-03t_.txt' every ::2 u 1:3:(1800):($3<0.2?.005:0.05):4 w boxxyerrorbars fs solid lc palette
The boxxerrorbars ... lc palette takes using <x>:<y>:<deltaX><deltaX>:<z>
The delta values are half the width of the boxes, i.e. it means plot a box from x-deltaX;y-deltaY to x+deltaX;y+deltaY for each datapoint.
Here, the width of the boxes is 3600 seconds, the height is either 0.1 or 0.01, depending on the y-value.
Here is the result:
However, you can still improve the height of the boxes.
And instead of 4+1 columns, you can also pass 6+1 columns with
using <x>:<y>:<xlow>:<ylow>:<xhigh>:<yhigh>:<z>
Here, the borders of the boxes are given as absolute values, not as distance from the x-y-value.
Currently I created graphs with small size. The spacing really important at this case. I want to add more vertical space between my xticlabels and x axis.
I have tried to set the x bar with
set xtics offset 0,graph 0.05
my gnuplot output:
The data and gnuplot script still same with my previous question here.
You can do the following:
First add a little bit of bmargin by
set bmargin 3
Since you need to add vertical space between your xticlabels and x-axis, you need to adjust the Y-offset, which can be done by the following
set xtics offset 0,-1,0
You can play around with the values to suite your need.