I tried searching, but I couldn't find the solution for this particular condition. In my plot , I am comparing two traces. I am using a line graph and both traces are plotted with different colors.
plot "delay_try1.dat" using 1:2 title 'With CloneScale' with lines, \
"normal_2.dat" using 1:2 title "Without CloneScale" with lines lc rgb "black", \
"normal2.dat" using 1:2 title 'Without CloneScale' with lines lc rgb "black"
Using this plot command, I get 3 titles in legends and 2 are repeating ones. I just want 2 titles to appear and remove the repeating one. Is it possible to do this?
To accomplish this you should use the notitle tag.
plot "delay_try1.dat" using 1:2 title 'With CloneScale' with lines, "normal_2.dat" using 1:2 title "Without CloneScale" with lines lc rgb "black", "normal2.dat" using 1:2 with lines lc rgb "black" notitle
or a more general example;
plot 'File.dat' using 1:2 notitle
an alternative that is equivalent to notitle is to set the title to a zero character string;
plot 'File.dat' using 1:2 title ""
If you had more untitled lines than titled lines, it's more convenient to disable titles by default using set key noautotitle:
set key noautotitle
plot "delay_try1.dat" using 1:2 title 'With CloneScale' with lines, \
"normal_2.dat" using 1:2 title "Without CloneScale" with lines lc rgb "black", \
"normal2.dat" using 1:2 with lines lc rgb "black"
If you are not above a bit of trickery:
Just omitting the last "Without CloneScale" title will remove both title and line from the legend.
Setting the last title to a space will show the line and (seemingly) nothing before it in the legend:
plot "delay_try1.dat" using 1:2 title 'With CloneScale' with lines,"normal_2.dat" using 1:2 title "Without CloneScale" with lines lc rgb "black", "normal2.dat" using 1:2 title ' ' with lines lc rgb "black"
Related
My Gnuplot 4.4 is plotting data from N files, each of which has an unknown number of NaNs (which won't be plotted). I've used the following "trick" to make all of the data appear to be part of the same data series:
plot "fileA.dat" using 1:2 linecolor rgbcolor #FF0000 title 'My data', \
"fileB.dat" using 1:2 linecolor rgbcolor #FF0000, \
"fileC.dat" using 1:2 linecolor rgbcolor #FF0000
Notice that the colours are the same, and the title is only given for the first file.
But, if fileA.dat has only NaNs (or for any other reason does not contain plottable information), the series is omitted and I don't get a title at all.
Can I make fileA.dat's legend entry show up regardless, or is there perhaps a better approach to "sharing" legend entries across series? Assume that I do not have any more information than already declared here, before invoking plot.
You can set the title on an "invisible function" like this:
plot "fileA.dat" using 1:2 linecolor rgbcolor "#FF0000" notitle, \
"fileB.dat" using 1:2 linecolor rgbcolor "#FF0000" notitle, \
"fileC.dat" using 1:2 linecolor rgbcolor "#FF0000" notitle, \
NaN linecolor rgbcolor "#FF0000" title "My data"
The linestyle of the explicit "NaN" can also be modified.
I understand that we can omit the key in GNUplot using unset key. If I want to insert a small image to signify the key onto a XY 2-D plot, how to do it? In MS-Excel, it is just a matter of copying an image and pasting it on to the plot and adjusting its placement and size. Can such a thing be done in GNUPlot too? By what plot option? I am attaching a sample a of what I expect in a multiplot I made (the plot on the top left). And I have the small molecule image as a png file. I have also listed the code below. Please help me. Thanks.
reset
set size 1,1
set multiplot
unset key
#CPD
set size 0.5,0.5
set origin 0,0.5
unset title
plot 'Practice1.dat' using 1:2 w points lw 3 lc rgb 'red'
plot 'Practice1.dat' using 1:6 smooth csplines lw 3 lc rgb 'red'
#Ethene
set size 0.5,0.5
set origin 0.5,0.5
set title 'Ethene'
plot 'Practice1.dat' using 1:3 w l lw 3 lc rgb 'blue'
#Benzene
set size 0.5,0.5
set origin 0,0
set title 'Benzene'
plot 'Practice1.dat' using 1:4 smooth csplines lw 3 lc rgb 'green'
#H2
set size 0.5,0.5
set origin 0.5,0
set title 'H2'
plot 'Practice1.dat' using 1:5 w l lw 3 lc rgb 'black'
The image will be a plot in itself.
plot "image.png" binary filetype=png center=(975,40) dx=200 w rgbimage, \
'Practice1.dat' using 1:2 w points lw 3 lc rgb 'red', \
'Practice1.dat' using 1:6 smooth csplines lw 3 lc rgb 'red'
Note that you should avoid having several plot commands without changing origin/size in multiplot, as the labels and borders are overlaid and this may change their appearance depending on terminal (because e.g of antialiasing), hence the usage of , and the splitting of the command on multiple lines (with \)
Note also that set multiplot could have done the layout of your simple 2x2 plot all by itself for you, set multiplot layout 2,2
I wrote the following "tmp.dat" datafile
\# 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20
\#inFile;cn;mv;nr;nd;nn;fil;sep;m#enn=;m#enn=;n=;i=;aLea1=;rLea1=;amea1=;rmea1=;NbaLea1=;NbrLea1=;Nbamea1=;Nbrmea1=;rrmen3a1=
ex32new_DMLPG_beta3_der1emeno5/fort.501;0;?;?;?;?;0.0110485435;0.0078125;14;11.1540828402;4225;0;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00172
ex32new_DMLPG_beta3_der1emeno5/fort.501;1;0.0165088727;1745;64;0;0.0441941738;0.0078125;42;11.2126074499;1745;1;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00172
ex32new_DMLPG_beta3_der1emeno5/fort.501;2;0.0165088858;1726;64;0;0.0441941738;0.0078125;35;11.2027809965;1726;2;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00272
ex32new_DMLPG_beta3_der1emeno5/fort.501;3;0.0165088801;1724;64;0;0.0441941738;0.0078125;39;11.214037123;1724;3;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00372
ex32new_DMLPG_beta3_der1emeno5/fort.501;4;0.0165088766;1720;64;0;0.0441941738;0.0078125;34;11.1831395349;1720;4;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00472
ex32new_DMLPG_beta3_der1emeno5/fort.501;5;0.0165088776;1718;64;0;0.0441941738;0.0078125;32;11.1850989523;1718;5;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00572
ex32new_DMLPG_beta3_der1emeno5/fort.501;6;0.0165088822;1710;64;0;0.0441941738;0.0078125;34;11.216374269;1710;6;0.00898;0.00158;0.00205;0.00205;0.00898;0.00158;0.00205;0.00205;0.00672
My gnuplot script
set datafile separator ";"
set datafile missing "?"
set grid
set xlabel "coarsening level"
set ylabel "rrmen3a1"
set xrange [-1:7]
set yrange [*:*]
set terminal pdf color
set output "tmp.pdf"
plot \
"tmp.dat" using 2:21 index 0 with lp title columnheader(1), \
# EOF
does NOT plot the "first" point (0, 0.00172), only points x=1,...,6
Any hint?
The issue is with your plot line
plot "tmp.dat" using 2:21 index 0 with lp title columnheader(1)
This instructs gnuplot to use your first record (which does not include commented lines) to use as column labels. So your first data line is being interpreted as a header. If you do not want to reformat your datafiles, you can plot a dummy curve with the same header file which will act as your data series label. Something like
plot "tmp.dat" using 2:21 index 0 with lp lt 1 lc rgb 'black' notitle, \
"tmp.dat" using ($0):(1/0) index 0 with lp lt 1 lc rgb 'black' columnhead(1)
Note that we have to manually specify the line styles to ensure the keys have the same linestyle as the curves.
I have a problem with gnuplot filled curves. I calculated some data to draw a picture using this code:
plot 'cont.dat' u 1:2 w filledcurves closed lc rgb "#ADFF2F" title "DF"
'cont2.dat' u 1:2 w filledcurve lc rgb "#CD5C5C" title "DA",\
'cont3.dat' u 1:2 w filledcurve lc rgb "#4682B4" title "(DF+DA)/2",\
'cont3.dat' u 1:2 w l lw 3 lc rgb "#4682B4" notitle ,\
'cont.dat' u 1:2 w l lw 3 lc rgb "#ADFF2F" notitle,\
'cont2.dat' u 1:2 w l lw 3 lc rgb "#CD5C5C" notitle
And everything was fine with this data:
But when I calculated another case. Trying to draw using the same code I received the following wrong result:
How could I change my code to fill the areas fully? I don't need this transparent 'holes'.
UPD:Here you can find data of green area which have been plotted wrong:
https://www.dropbox.com/s/xzheur2mx9h902f/cont.dat?dl=0
It doesn't matter either you plot three curves ore just one the result for each curve is the same.
I used GNUplot 4.6 for Windows
As mentioned in the comments, one of the problems in your data is that it is separated into blocks. But solving this issue is not enough. Let us focus in the figure below:
The figure on top corresponds to your original data. I plotted each data-block with different colors. If we remove the white spaces, the middle/blue figure is obtained, so the issue is not resolved yet.
If you look into the data, the first column of each data-block is sorted in the direction of the arrows (top figure), but the data-blocks are sorted in the opposite direction: They are disconnected!
So, the data-blocks should be sorted as 0-4-3-2-1 (or any cyclic order, such as 3-2-1-0-4). The white spaces should also be removed. Once you do this, the bottom/red figure is obtained.
This is part of the code I used to draw the picture:
plot for [i=0:4] 'cont_original.dat' u 1:2 every :::i::i w filledc t 'original block '.i,\
'cont_nospaces.dat' u 1:($2-0.2) w filledc t 'original without spaces',\
'cont_ordered.dat' u 1:($2-0.4) w filledc t 'ordered'
I'm trying to plot two data series in the same graph with multiplot. I would like each of the two data series to be plotted with a different palette. So far I've been trying with multiplot,
set multiplot layout 1,1
#
set palette rgb 21,22,23
splot "S1" using ($1):($2):($3):($5) with points pt 7 ps 3 palette notitle, \
"S1" using ($1):($2):($3):($5) with impulses linecolor "black" notitle
#
set palette rgb 23,28,3
splot "S1" using ($1):($2):($3):($5) with points pt 7 ps 3 palette notitle, \
"S2" using ($1):($2):($3):($5) with impulses linecolor "black" notitle
#
unset multiplot
however, I can not visualize in the X11 terminal the two series at the same time.
Any idea?