i want to generate some plots from my data that i want to include in some documentation.
I put the box outside the graph area.
the problem is that for different plots the box has different sizes so also the graph area changes its size. this looks very messy in the document becasue the plots are vertical aligned.
I am searching for a way to fix the size of the box to some width that is appropriate for all plots but i could not found a way to do so.
the set key command has a width parameter but it seems not to do that one would expect from such a parameter.
It would be grat if someone could help.
thanks
vlad
I hope I got the correct impression of what you want. Consider the following example
reset
set multiplot layout 2,1
set rmargin screen 0.7
set key reverse Left left top at screen 0.72, graph 1
plot sin(x), cos(x) t 'long title'
plot sin(x), cos(x) t 'very long title'
unset multiplot
Which gives you:
Both the samples and the text do not move. You must only set an appropriate rmargin. left and top is the key box alignment regarding the position specified with at ..., although these settings are default, I explicitely included them for clarity. Left is the alignment of the entry text.
Related
I am using gnuplot with epslatex terminal. I want to know how to put the
label on top of a margin, so that the part of margin under the label is invisible. In the figure I attached, the part of margin under the label
is still visible.
In principle you should be able to tell gnuplot to put your text labels into a box by using the set label ... front boxed, and the specify that the box should be opaque and white using something like set style textbox opaque noborder fillcolor rgb "white". However, this is not supported by all terminals, and epslatex seems to be one of those where this doesn't work.
However, in epslatex you can simply use latex commands to create a white background box around your label text:
set term epslatex standalone
set outp "test.tex"
set label "\\colorbox{white}{This is a label}" at 6.,0.5 front
plot sin(x)
set output
gives
I am trying to move the legend of a plot in gnuplot partially outside the plot area. It seems however that the plot border is visible inside the legend, even if I set the legend property to opaque.
A minimum example showing the problem:
#!/usr/bin/gnuplot -persistent
set key at 11,1.02 box opaque
plot sin(x)/x
So, I wonder how I should go about in order to make the entire interior of the key opaque white? I've thought about putting a white rectangle behind it, but it seems to be a kind of dirty solution.
The opaque option of the key does indeed draw a white rectangle, but the border is drawn on top of the key. Use set border back to draw the border behind the key:
set key at 11,1.02 box opaque
set border back
plot sin(x)/x
There isn't an option to set the key color directly; people tend to resort to either drawing a box under the key (as you were thinking) or more complicated methods.
One workaround is to get rid of the plot border for the top and right edges of the plot (since the information there is redundant anyway):
set border 3
set tics nomirror
plot sin(x)/x
Another possibility is simply moving the key--does it need to be right on the edge of the plot? It could be further inside or outside.
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.
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.
I am generating mapped 3D plots using the following config file (XRANGE and YRANGE are set later)
#!/usr/bin/gnuplot
reset
set term postscript eps enhanced
set size square
set xlabel "X position"
set ylabel "Y position"
#Have a gradient of colors from blue (low) to red (high)
set pm3d map
set palette rgbformulae 22,13,-31
set xrange [0 : XRANGE]
set yrange [0 : YRANGE]
set style line 1 lw 1
unset key
set dgrid3d 45,45
set hidden3d
splot "data.data" u 1:2:3
The resulting image looks something like this
Note: I have converted to jpg so the quality is lower, and I have placed a border around the image.
A great deal of space is wasted above and below. This is not a problem until I embed the image into a LaTex document, at which point it will look like so (again, pdf document converted to jpg image)
The image on the right is also created with GnuPlot, but it is slightly larger (as is evident by looking at the border I have drawn around the top two images). The reason for this is because GnuPlot pads the 3D plot with top and bottom white space. How can I remove this without having to manually edit all 50+ plots I have?
There are two solutions to this, one is unreliable, the other is a hack.
Using GnuPlot, the margin settings can be used to specify distances from the appropriate margins. For example, setting lmargin 0 and bmargin 0 essentially pushes the axes off the page. Similar values can be assigned to the tmargin and rmargin to stretch the graph. Although this worked for 2D graphs, it did not work for 3D graphs (I suspect this has to do with the fact that I set the graph to be a square).
When graphs are set to be of square size, Gnuplot still calculates for the entire screen. The eps file can be manipulated directly to change this by looking for a line like so %%BoundingBox: 50 50 410 302 and changing 410 to something smaller. Alternatively, and this is what I did, you can run eps2eps in.eps out.eps and it will crop it for you. Just make sure in.eps is not the same file as out.eps or it won't work.
I also crop the Bounding Box afterwards, since I hate playing around with margins in gnuplot. I realized that somehow, eps2eps indeed does adjust the bounding box, but it also transforms text (labels etc) into pixel-graphic?!
I usually use "epstool" which conserves text as text when croping the bb, the command I use is:
epstool --copy --bbox in.eps out.eps
Use the <scale> argument in set view, this will magnify the plot without changing text size or title position.
In your case, because you use the map view, you need:
set view 180,0,1.5
where 180,0 is equivalent to map view and 1.5 is the scaling factor.