How to make key colour black in Gnuplot - colors

How can I make the key "symbols" black in colour when using palettes?

I think you cannot control this directly, here a workaround:
plot 'MOD1.dat' u 2:3:1 w p pt 7 ps 2 lt black, \
'MOD1.dat' u 2:3:1 w p pt 7 ps 2 lt palette notitle
So, we first plot the data without legend in black, then plot the data points but no legend. The nice thing about this approach is that there is no need to fix the x or y range.

I would just create a dummy line and use notitle on the real lines. Something like
set yrange[0:1]
plot "realdata1.data" u 1:2 w linespoints lt 1 notitle , \
"realdata2.data" u 1:2 w linespoints lt 2 notitle , \
1/0 w linespoints lt 1 lc rgb 'black' title 'Model1', \
1/0 w linespoints lt 1 lc rgb 'black' title 'Model2'
Then replace lt 1 with whatever you have used for style in your current plot. Note that you'll need to use set yrange for gnuplot to accept the dummy curve

Related

gnuplot 5.5: no auto axis limits

I've installed gnuplot 5.5 from git. Now it doesn't plot with automatic axis limits.
Here is the graph produced with earlier version (5.3 or 5.4):
And this is plotted with current version:
Here is the command for this plot:
plot [][3.0145:3.5755] 3.04 w filledcurves x1 fc rgb "#d9d9d9" notitle, \
3.55 w filledcurves x2 fc rgb "#d9d9d9" notitle, \
for [i=1:11] 'gpdata.dat' every :::0::0 using 1:i+1 lt i+1 lw 3 ps 1.5 t word(elements,i) w linesp,\
3.04 w lines lw 4 lt 1 lc rgb "red" t 'Допуск',3.55 w lines lw 4 lt 1 lc rgb "red" notitle
When I set the limits explicitly: plot [:35064.46][3.0145:3.5755] I get this:
i.e. the end points are hidden.
Is there a way to return previous behavior?
According to the StackOverflow "rules": no answer in the comments...
set xrange[:] noextend
should avoid the extension of the plotting range to the next "nice" tic. Check help noextend.

How do I add more space using gnuplot yerrorbars when I have a lot of data on my chart?

I added the yerrorbars keyword to show the standard deviation on my chart but because I have a lot of data the plot is not very clear and the std deviation as well. I would like to add more spaces when showing the standard deviation in the same way that is added on the line style using pi : set style line 4 lc rgb '#000000' lt 3 lw 1.5 ps 0.5 pt 3 pi 15. How would I do that?
set label 1 "(a) workload: 50K r/s\npre-agg 77K tuples" at "300",6.5 font "{,10}"
plot t=0 "throughput-vs-latency-50K-8combiners-8reducers-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000):(column(3)/1000) skip 2 notitle with linespoints ls 1 axis x1y1 \
, t=0 "throughput-vs-latency-50K-8combiners-8reducers-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)/1000) skip 2 notitle with linespoints ls 2 axis x1y1 \
, t=0 "throughput-vs-latency-50K-8combiners-8reducers-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(6)/1000) skip 2 notitle with linespoints ls 3 axis x1y2 \
, t=0 "throughput-vs-latency-50K-8combiners-8reducers-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(8)/1000):(column(9)/1000) skip 2 notitle with yerrorbars ls 4 axis x1y2 \
I think you would have to split the curve for that data into two parts.
The first part would draw the lines and points for every point in the data set;
the second part would draw errorbars only for every Nth point. The keyword needed is every N.
set errorbars lt -1
plot $DATA using 1:2 with linespoints lt 3 notitle, \
$DATA every 5 using 1:2:3 with yerrorbars lt 3 title "DATA"
Another suggestion: instead of crowded errorbars, why not an "error-shade"?
Code:
### shaded area as error "bar"
reset session
# create some test data
set table $Data
plot '+' u 1:(sin($1)):(rand(0)+0.25) w table
unset table
set key invert
plot $Data u 1:($2-$3):($2+$3) with filledcurves lc rgb "light-grey" ti "Error", \
'' u 1:2 w lp ti "Data"
### end of code#
Result:
For many data points with errorbars, consider set bar 0, error bars in the background, and/or transparency. Also point size can be reduced.
set samp 2000
set table $Data
plot '+' u 1:(sin($1)+(rand(0)+0.25)):(rand(0)+0.25) w table
unset table
set bar 0
plot $Data with err lc rgb "grey" ti "Error", \
'' u 1:2 w p lc "black" pt 6 ti "Data"

Combining acspline with filledcurve on data

I know how to use filledcurve with using 1:2:3 to fill the area between the curves described by columns 2 and 3.
I also know how to smooth a single curve using acsplines with using 1:2:(0.1) (with 0.1 being the smoothing weight for each point).
But I fail to combine the two, i.e. fill the area between two smoothed curves. All variants I try give me error messages like duplicated or contradicting arguments in datafile options.
This is what I tried:
plot 'datafile' using 1:2:3:(0.1):(0.1) smooth acs with lines
plot 'datafile' using 1:2:(0.1):3:(0.1) smooth acs with lines
Is this combination possible at all? How is the syntax then?
I guess you can't combine smooth acspline and with filledcurves, but I also don't know why this shouldn't be possible.
Well, as a workaround, plot your smooth acspline curve into a data table first and then plot it with filledcurves.
Code:
### filled acspline curve
reset session
$Data <<EOD
1 2
2 4
3 3
4 1
EOD
# plot your acspline data into a table
set table $ACSpline
plot $Data u 1:2 smooth acspline
unset table
set style fill transparent solid 0.1
plot $Data u 1:2 w lp pt 7 lc rgb "black" ti "Original data", \
$Data u 1:2 smooth acspline lw 2 lc rgb "red" ti "acspline", \
$ACSpline u 1:2 w filledcurves x1 lc rgb "red" ti "acspline filled"
### end of code
Result:
Addition:
There is another way to get data into a table. Check help set print.
With this, you can get the data of the two splines into one datablock and can plot the area between them. Maybe someone knows a simpler way to achieve this.
Code:
### filled curve between two acsplines
reset session
$Data <<EOD
1 2 4
2 4 1
3 3 0
4 1 3
EOD
# plot your acspline data into tables
set table $ACSpline1
plot $Data u 1:2:(1) smooth acspline
unset table
set table $ACSpline2
plot $Data u 1:3:(1) smooth acspline
unset table
set print $BetweenSplines
do for [i=1:|$ACSpline1|] {
print sprintf("%s %s %s",word($ACSpline1[i],1),word($ACSpline1[i],2),word($ACSpline2[i],2))
}
set print
set style fill transparent solid 0.5
plot $Data u 1:2 w lp pt 7 lc rgb "black" ti "Original data col 2", \
$Data u 1:3 w lp pt 7 lc rgb "blue" ti "Original data col 3", \
$ACSpline1 u 1:2 w l lw 2 lc rgb "red" ti "acspline col 2", \
$ACSpline2 u 1:2 w l lw 2 lc rgb "green" ti "acspline col 3", \
$BetweenSplines u 1:2:3 w filledcurves lc rgb "yellow" ti "acspline filled"
### end of code
Result:

Gnuplot line and key colors

I'm trying to use Gnuplot to create a line chart. Each line is represented by a different color. What I want is the key has the same color as the line color. This is what I have right now, current version. Is it possible to set the text 'Line 2' colored as orange, 'Line 3' colored as red, etc?
This is what I wrote in the gp file:
set xlabel'x-axis'; \
set xrange[0:25];\
set ylabel 'y-axis';\
set yrange [2:9];\
set key left top;
p 'test.dat' using 1:2 w linespoints lw 5 lc rgb '#aadc32' pt 17 title 'Line 1' ,\
'test.dat' using 1:9 w linespoints lw 5 lc 'orange' lt 1 title 'Line 2',\
'test.dat' using 1:6 w linespoints lw 5 lc 'red' lt 8 title 'Line 3',\
'test.dat' using 1:7 w linespoints lw 5 lc 'violet' pt 6 title 'Line 4',\'test.dat' using 1:8 w linespoints lw 5 lc rgb '#b5367a' pt 19 title 'Line 5',\
'test.dat' using 1:3 w linespoints lw 5 lc 'cyan' pt 9 title'Line 6',\
'test.dat' using 1:4 w linespoints lw 5 lc 'blue' lt 9 title 'Line 7',\
'test.dat' using 1:10 w linespoints lw 5 lc rgb '#1c1044' lt 5 title 'Line 8',\
Thank you so much.
Unfortunately not. The plot title does not (now, gp5.2pl0) recognise the "textcolor" specifier.
plot x lw 3 lc rgb "blue" title "x" tc rgb "blue" # doesn't work
You can only print an empty (" ") plot title, and overprint it with a coloured label
set label 1 at 8,1 "bluetitle" tc rgb "blue"
That requires some fiddling with the placement of the label, of course.
You might put up a feature request on https://sourceforge.net/p/gnuplot/feature-requests/

Same Gnuplot linestyle as in graph in key/legend

I would like to plot a legend/key, which shows the different symbols on the line. Currently my plots look like this:
Unfortunately the symbols (triangle, rectangle and circle) are not shown in the key/legend. How is it possible to add them?
I use the following gnuplot script:
set title tit font "palatino,20"
set xlabel xlbl font "palatino,20"
set ylabel ylbl font "palatino,20"
#set logscale x
set output graphfilename.".pdf"
set terminal pdf
set border linewidth 2
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 5 # --- blue
set style line 2 lc rgb '#00ad60' lt 1 lw 2 pt 7 # red .
set style line 3 lc rgb '#ad0000' lt 1 lw 2 pt 9 # green .
set tics scale 0.8
set key below
plot file1 using ($1/1000):($2/1000000):($3/1000000):($4/1000000) notitle w yerrorbars ls 1, \
'' using ($1/1000):($2/1000000) title "Hlog" w lines ls 1,\
file2 using ($1/1000):($2/1000000):($3/1000000):($4/1000000) notitle w yerrorbars ls 2, \
'' using ($1/1000):($2/1000000) title "Iris" w lines ls 2,\
file3 using ($1/1000):($2/1000000):($3/1000000):($4/1000000) notitle w yerrorbars ls 3, \
'' using ($1/1000):($2/1000000) title "Java" w lines ls 3
Generally, you can get both lines and points, if you plot with the linespoints plotting style:
sc(x) = x*1e-6
plot file1 using ($1/1000):(sc($2)):(sc($3)):(sc($4)) notitle w yerrorbars ls 1 ps 0.5, \
'' using ($1/1000):(sc($2)) title "Hlog" w linespoints ls 1
That draws the points twice, which shouldn't be a problem unless you use transparency. I also shrinked the points which are drawn together with the errorbars to 50%, so you don't get problems with antialiasing.
As another option you could add the title only the the errorbars, in which case the legend would look like |---x---| (i.e. contain also the errorbars):
sc(x) = x*1e-6
plot file1 using ($1/1000):(sc($2)):(sc($3)):(sc($4)) title "Hlog" w yerrorbars ls 1, \
'' using ($1/1000):(sc($2)) notitle w lines ls 1

Resources