gnuplot: how to set error bars and label simultaneously - linux

I want to plot a curve that has error bars. I used with yerrorlines for that.
Now I want to show a label for each point that should be done by: with labels
How can I use both of them simultaneously? I tried with yerrorlines ,labels but not worked!

You must plot the data twice:
plot 'data' using 1:2:3 with yerrorlines title 'title',\
'' using 1:2:4 with labels offset 0,2 notitle
You must probably adapt the label offset such that the label it doesn't overlap with the error bars.

Related

How to show a grid with two filled plots

I am plotting to datasets with 'fillsteps' one below another and I want the plot two show only the area that is a difference between the two
plot [0:1][0:1] x with fillsteps above fill solid not,x**2 with fillsteps above fill solid lc rgb 'black' not
But the grid obviously gets blocked in this case:
Is there any way to create something like a cross-section between the two areas, show the grid and get rid of those nasty artifacts that are seen below?
Ok, basically you want to fill the area between two curves (either lines or steps) and have a grid on top. The set grid front you found yourself, but let me make another suggestion.
For the first case (lines), i.e. a fill between lines, you can simply use 3 columns (check help filledcurves) and then the area will be filled between the curves:
plot '+' u 1:(f1(x)):(f2(x)) w filledcurves
For the second case (steps), I don't see (yet) such an option with filledsteps. Actually, from your option above I assume you are using gnuplot5.5.
In general, I wouldn't call it a "clean" solution if you plot something and partly have to cover it with something else with background color. What if you want a transparent background? A transparent color which covers something colored has not yet been invented ;-), there is no such "invisible" color. For another example check this.
Furthermore, with fillsteps I can also observe the artifacts of vertical gap lines which you see in your graph, but I don't have a good solution to avoid them.
Hence, my suggestion is to plot only there where you need something to plot. Actually, you can mimic the fillsteps behaviour. It's not obvious how to do it, but not too difficult. While you plot line by line, you remember the previous x-value and function values of f1(x0) and f2(x0) in x0, y0 and y2, respectively. You plot with the plotting style boxxyerror (check help boxxyerror) using x:y:xlow:xhigh:ylow:yhigh.
Script: (works with at least gnuplot>=5.0.0)
### plotting style filledcurves and mimic fillsteps "between"
reset session
f1(x) = x
f2(x) = x**2
set xrange[0:1]
set yrange[0:1]
set key noautotitle
set grid x,y front lw 1.3
set style fill solid 1.0 border
set samples 50
set multiplot layout 2,1
plot '+' u 1:(f1(x)):(f2(x)) w filledcurves
plot x1=y1=y3=NaN '+' u (x0=x1,x1=$1):(y0=y1,y1=f1($1),y2=y3,y3=f2($1)):(x0):(x1):\
(y0):(y2) w boxxy
unset multiplot
### end of script
Result: (download the PNG image and check that the background is transparent).
set grid front
works in this case

Gnuplot - Multiplot autoscale displays x-axis and y-axis units twice on each other

In Gnuplot I want to display 2 plots on the same graph with the help of multiplot. The display works fine, but the scaling redisplays and the same units are put on each other, because i use autoscale.
My question is, how do i display the scaling only once?
Here is my code:
set border 1023-128
set autoscale
set multiplot
plot strDsDir.strInputFile using 1:($6/1000000) skip 1 w filledcurves x lc rgb "#00aa22"
replot strDsDir.strInputFile using 1:($7/1000000) skip 1 w filledcurves x lc rgb "#80e45f"
unset multiplot
I tried unsetting autoscale, between the "plot" and "replot", but then I lose autoscaling, and graphs slip.
I also tried unsetting xtics and ytics, but then i lose the set border 1023-128 above.
Here is the picture, where my units lapse on eachother :
And here is the picture, where units dont lapse on each other, but my "set border option" disappears :
The dataset what im trying to display doesnt matter.
Thank you.
The purpose of multiplot usually is to plot several plots beside each other. If you want to plot several curves in a single plot, use a single plot command like plot x, x**2:
plot strDsDir.strInputFile using 1:($6/1e6) skip 1 w filledcurves x lc rgb "#00aa22", \
"" using 1:($7/1e6) skip 1 w filledcurves x lc rgb "#80e45f"

Plot contours from one graph into another in Gnuplot

I have a data file with four columns X Y Z1 Z2 and I want to create a seperate color plot for each Z but plot contour lines from the first one also into the second one.
First I create a plot for Z1 and the contour file with
set terminal "pdfcairo" enhanced dashed size 5,5
set output "Output1.pdf"
set pm3d
unset surface
set view map
set contour
set cntrparam levels discrete 1.45,1.50
set table 'DATAFILE.contourZ1'
splot 'DATAFILE' using 1:2:3 notitle with lines
unset table
splot 'DATAFILE' using 1:2:3 notitle with lines
unset output
This gives me the color plot with two contour lines along Z1=1.45 and 1.50. So far so good. To load the contours into the second plot I tried
splot 'DATAFILE' using 1:2:4 notitle with lines,\
'DATAFILE.contourZ1' using 1:2:3 notitle with lines
but this only gives me the colorplot for Z2 without any contour lines.
Does anyone know, how I can accomplish this? If it's not possible in such an easy way as I have tried, I'm open for other ways, too :)
Thank you very much!
You have to unset pm3d before saving the table file so that you get a file with only the contour-line points.
Then if you want to plot pm3d and lines you might want to use set pm3d explicit and a splot "contour.txt" with lines, "data" with pm3d.

Gnuplot plot error bars every 10 data points

I want to plot my data with error bars. It is to do with the syntax
plot "xyz.dat' u 1:2:3 w yerrorbars
However, since my data file has 10000 data points, plotting all error bars would make the error bars overshadow the line shape of the data. So I want to plot error bars every 10 data points. How can I do that?
Try
plot "xyz.dat" u 1:2:3 every 10 w yerrorbars
Also look at:
How do I plot every nth point

How to add custom label to Gnuplot graph legend?

In a graph I'm making with gnuplot I draw some grey lines (set arrow command), which represent the physical boundaries of my experiment (i.e., walls)
I would like to know how I can add this information on the legend of the graph, so it says "Walls" and have a grey line next to it.
I thought about creating a new series that contained this information, but I was wondering if it's possible to explicitly add it.
You can't add information directly to the legend. You can, however, either draw the legend explicitly, or plot a line which will not appear within the range of the plot, e.g.
plot [][0:1] 2 lc rgb 'gray' t 'Walls'
Or, if your x and y limits are already set:
...
[set x and y limits here]
...
plot 1e20 lc rgb 'gray' t 'Walls'
Just wanted to note: since plotting a single line tended to mess up a graph of mine, a better solution for me was to plot a single point; but as found in Plotting single points « Gnuplotting, that is kinda difficult (especially if insertion at arbitrary plot legend/key position is needed) - unless redirection is used... This is what worked for me:
plot "filename" using 1:8 \
,\
... # more plot lines here
,\
"<echo '-1 -1'" lc rgb 'white' with points title '---' \
,\
... # more plot lines here
One simple way is to make the name of the data file the legend which you want and then plot that data file.

Resources