Gnuplot key: sample and title positions - gnuplot

Is it possible to adjust the relative vertical position of the sample in a key
and its title? Running these commands
set terminal pdfcairo
set output 'foo.pdf'
set yrange [-1.2:1.2]
plot sin(x)
produces a plot with a key that looks like this:
I'd like the sample in the key to be a bit lower relative to the title in the key (or the title in the key a bit higher relative to the sample in the key).
EDIT: There seem to be other issues with alignment, not just in the key. This is the whole graphic produced by the commands above, using the latest Gnuplot installed by homebrew on OSX 10.10.5 (Gnuplot 5.2.2, cairo 1.14.12). The same thing is evident on OSX 10.11.6. At least some of the labels on the xaxis seem to be shifted a bit to the right of the tic, and labels on the yaxis seem to be shifted down.

help set key provides you with all necessary details. In your case, probably
set key left
would already help. But there is also the option to tell gnuplot precisely where you want the key to be placed, using
# This places a key at coordinates x = 6.5 and y = 0.8 in the coordinate system:
set key at 6.5,0.8
Another way, rather than playing around with key positions, is also to adjust the range in a way that comfortable space is left for the key, in your case
plot [-10:+10][-1.1:1.2] sin(x)
might help.

Related

Reverse abscissa/ordinate axis in wxdraw2d or wxplot2d wxmaxima

By default, the draw/plot function plots y-axis values in ascending order (from bottom to top). In other words, -ve values are at the bottom of the graph and +ve values above the origin (towards the top of the plot). Can we reverse (see the figure attached) this behavior for the individual axis or both?
It is possible in gnuplot, by passing set xrange reverse and set yrange reverse, but wxmaxima does not provide a full interface for gnuplot, however, it seems that direct access may be possible. As from the docs:
2.3.5 Opening gnuplot’s command console in plot windows
On MS Windows, if in Maxima’s variable gnuplot_command “gnuplot” is replaced by “wgnuplot”, gnuplot offers the possibility to open a console window, where gnuplot commands can be entered into. Unfortunately, enabling this feature causes gnuplot to “steal” the keyboard focus for a short time every time a plot is prepared.
Please also note that there is a difference in gnuplot 4 and 5:
The reverse keyword of the set [axis]range command aects only autoscaling. It does not invert or
otherwise alter the meaning of a command such as set xrange [0:1]. If you want to reverse the direction
of the x axis in such a case, say instead set xrange [1:0].

Gnuplot pm3d at sb

This is my second question today, I thought about editing the other one with this info but the problems doesn't seem to be related... So, with this data file, and using this code:
set terminal qt
s=101
set size square
set palette rgb 34,35,36;
set zrange[-1.8e-5:1.8e-5]
set pm3d at sb
set autoscale fix
do for [i=0:0]{
splot 'itp.txt' u 1:2:3 every:::(i*s)::(s+i*s) notitle w pm3d
}
I get this black image. This is clearly not working properly... but if I slide my finger through my notebook's touchpad while in the qt's output interactive window, this image pops up, which is what I wanted. It seems to work everywhere, except when the graph fit the "canvas". Example 1 & example 2. I'm not even sure what sliding my fingers through the touchpad while on qt's output window does, but it seems to be fixing something. So what should I do? Thank you in advance!
*qt is the qt terminal in gnuplot
Looking at the two figures you posted, it seems that the effect has to do with a changing xrange. I copied your datafile and script, and adding:
set xrange[-200:300]
did the trick for me. Also, you may consider fixing (if at all possible) your color bar range, by adding:
set cbrange[xx:xx]
with your data, I tried:
set cbrange[0:1.8e-8]
and the result looks completely different. Hope this helps.

How can I blank out the background of the key in gnuplot?

My plot is covering up my key in gnuplot. What I'm plotting oscillates a lot, so there's nowhere on my plot I can go and not interfere with something. How can I give the key an opaque background so that the items inside aren't covered up by lines?
My version of gnuplot supports opaque keys via:
set key opaque
Try out the following:
set key box opaque
plot sin(x)
Another option in cases like these is to move the key outside the plotting area:
set key outside
plot sin(x)
This way you don't obscure any of your valuable data.

Why doesn't the gnuplot grid extend over this whole plot?

Using gnuplot 4.6 patchlevel 1, with the following commands,
set grid linewidth 1 linecolor rgb"#888888"
set datafile separator ","
plot for [n=2:100] "data.csv" using 1:(column(n)) with lines linewidth 2
and the following example data in the file "data.csv",
time,S1,S2
0,0.00015,0
0.1,0.0001357256127053939,1.427438729460607e-005
0.2,0.0001228096129616973,2.719038703830272e-005
0.3,0.0001111227331022577,3.887726689774233e-005
0.4,0.0001005480069053459,4.945199309465411e-005
0.5,9.097959895689501e-005,5.902040104310499e-005
0.6,8.232174541410396e-005,6.767825458589604e-005
0.7,7.448779556871142e-005,7.551220443128858e-005
0.8,6.739934461758323e-005,8.260065538241677e-005
0.9,6.098544896108986e-005,8.901455103891014e-005
1,5.518191617571635e-005,9.481808382428365e-005
the resulting plot looks this:
Question: why does the grid only extend partway from the bottom, and not cover the whole plot? I tried a considerable amount of experimentation with the set xtics and ytics commands, arguments to grid, and more, and have not been able to get the grid to cover the whole plot. What am I missing?
Great question! In fact, the answer is that the grid does cover the whole plot. The problem is that the key is taking over. Try it again, but with an unset key in there before your plot command.
What's happening is that gnuplot is reserving space in the key for all of the columns which have no data. Nothing gets put in the space that was reserved since no reasonable data was found. Ultimately, this pushes the 2 lines that were visible out of the viewable canvas area as well.
I've reproduced this using the x11, png, postscript and pngcairo terminals.
Note that this behavior seems to be version dependent:
With gnuplot 4.4.2 (OS-X, png terminal)
With gnuplot 4.6.0 (OS-X, png terminal)
For those using gnuplot 4.4.4, perhaps there was a bug fix which made it work for gnuplot 4.4.4 and then a regression. It seems to persist into gnuplot 4.7.0 as well. I might file a bug report.

How increase the size of the legend in Gnulot

Can someone please direct me as how to increase the size of a legend in Gnuplot.
I wish to place the legend outside with:
set key outside top
But now I want the legend to appear larger in size. How can this be done?
The font specification can follow the setting of key, from help key:
{font "<face>,<size>"}
You do not need to specify the face if you only want to change the size, e.g. to set font size to 16 do this:
echo 'set key outside top font ",16"; plot sin(x) w l' | gnuplot --persist
Which fonts are available depends on the terminal setting, e.g. if your terminal is wxt, you can find out more by running help wxt, etc.

Resources