Can parameters passed to `replot` replace previous plot parameters? - gnuplot

The replot command can take new plot parameters and output a new plot over the previous one. This is possible because the docs say that there is an implicit comma between the previous plot and any arguments passed to replot.
Is there a setting that will take new parameters and instead apply them directly to the previous plot, or overwrite the previous parameters?
For example, say I plot:
plot sin(x)
But now I want to plot it with dots. Is there a way to modify this plot with this?
replot with dots
This type of syntax would make it easier for me to iterate on a single plot interactively until it's right.

Not exactly. But you can change the default plot style or the properties of the lines and then replot:
set style function points
plot sin(x)
set style function lines
replot
set style function linespoints
replot
set linetype 1 pointtype 7 pointinterval 5
replot

Related

How to set a legent without points and duplicate with in the plot?

I would like only the title in the legent without point.
When I plot yerrorbar, there is an error:
duplicated or contradicting arguments in plot options
How to rewrite it?
set key tc variable
plot 'file.txt' with points pt 7 title "A" with yerrorbar
If something is missing in my question, let me know please.
In recent gnuplot versions there is a separate option keyentry (introduced in version 5.2.6).
The documentation says
gnuplot> help keyentry
Normally each plot autogenerates a single line entry in the key. If you need
more control over what appears in the key you can use the `keyentry` keyword
in the `plot` or `splot` command to insert extra lines. Instead of providing
a filename or function to plot, use `keyentry` as a placeholder followed by
plot style information (used to generate a key symbol) and a title.
Example
set key box width 3
plot 'file.txt' with points pt 7 notitle, keyentry title "Some Title"
In older gnuplot versions a work-around is to plot some function that lies entirely outside the plot and give it the desired title. This may generate warning messages such as "all points out of range" but it does place the title in the key. Example below. Note that the pointtype is given as an empty string.
set yrange [0:*]
plot 'file.txt' with points pt 7 notitle, -1 with points pt '' title "Some Title"

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 one single curve with different successive colors with gnuplot

Using gnuplot I would like to plot a data set, signal vs. time (let's say a chromatogram) with different colors for selected regions of the curve (let's say peaks) but I am not sure whether it is possible or not.
What I tried so far is something like:
plot [2:4.6] [0:100] 'data.csv' using 1:2 with lines lt 1,\
[4.6:4.7] [0:100] 'data.csv' using 1:2 with lines lt 2,\
[4.7:6] [0:100] 'data.csv' using 1:2 with lines lt 3
but it does not seem to work, since I only get the 'invalid expression' message.
Use linecolor variable to dynamically specify from which line type to take the color:
lt(x) = (x >= 4.7 ? 3 : (x >= 4.6 ? 2 : 1))
plot 'data.csv' using 1:2:(lt($1)) linecolor variable
Although the method proposed by Christoph answer is good for a limited number of color changes, it may be long and complicated to set up in my case since my real data set will have many peaks and many changes of color.
I found a better one based on this question gnuplot: yerrorbars with linecolor variable, it simply consists in using a third column (which can simply be added using a spreadsheet) to set the color of every data point with the gnuplot code:
plot [2:6] [0:100] 'data.csv' using 1:2:3 linecolor variable with lines notitle

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.

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