gnuplot - distance between columns in a key [duplicate] - gnuplot

Please have a look at the attached plot created from Gnuplot. I am facing two issues with it.
1) The empty white space in the left side of the key box (legend box). Is there any way to remove that extra empty white space? Neither I want to lose the key box nor compromise on the Greek letters used. Also, note that final output format has to be eps.
2) There is also too much space between the y-axis and the y-label. How to optimize it?
Please help.
Gnuplot_Image

Gnuplot doesn't know the exact width and height of the ultimately formatted strings. It rather tries to approximate the width based on some font information. That does also happen when using e.g. the qt terminal with a title containing only very narrow letters:
set terminal qt
set key box
plot x title 'iiiiiiiiiii'
That becomes even more complictated when TeX strings are involved. Use the width parameter for set key with a narrow value to decrease the key's width. You must manually estimate the actual value to use:
set terminal qt
set key box width -6
plot x title 'iiiiiiiiiii'
The same argumentation applies to the positioning of xlabel and ylabel. Here, you must use the offset parameter to correct the position:
set xlabel 'xlabel' offset 0, -0.5
set ylabel 'ylabel' offset 0.5, 0

Related

Space in legend between symbol and text in gnuplot

Dear Experts of gnuplot,
I want to change the spacing between key text and key symbol.
Please help me with this. What command should I use for the purpose?
Thanks in advance.
The space between symbol and key entry is so large because it is reserved for line plots:
plot sin(x) with points, cos(x) with lines
If you mix these two styles in one figure, you will want to keep the horizontal spacing. However, if you are sure that you will use only points, then the horizontal space might indeed seem too large. The samplen option of set key can be used for that purpose, it can even be set to negative: set key samplen -1 (default is 4)

Text label over point gnuplot

I would like to insert a text label (Latex style) close to a point as in the image shown in the following. Unfortunately I could only find examples that let to plot, for example, the coordinates of the point as label but nothing related to the text labels
Not sure I understand the question, but as a starting point I point out that all labels in gnuplot are anchored to some position, and have an optional property "point" that draws a symbol at that anchor position. Whether that is left, right, or center with respect to the text depends on the text justification, futher modifiable using "offset".
Example:
f(x) = x + 2*sin(x)
set xrange [0:10]
set border 3
set tics nomirror
# gnuplot enhanced text version
set label 1 "V_p" at 3,f(3) point pointtype 7 offset 0,1
# LaTeX version
set label 1 "$V_p$" at 3,f(3) point pointtype 7 offset 0,1
plot f(x)
caveat: the position of the label is evaluated at the time of the set label command, so if you change the definition of f(x) later you would have to re-execute the set label.
2nd caveat: If plot is to be generated using one of gnuplot's LaTeX terminal (pslatex, tikz, cairolatex, ...) then all the text used, including the label, must conform to LaTeX syntax rather that gnuplot's own text markup. Generally this means enclosing simple expressions in $...$ and using LaTeX macros for odd characters rather than UTF-8. In order for the leading backslash of the macros to be passed through, use single quotes rather than double quotes:
gnuplot non-latex terminal: set label "a→∞"
gnuplot latex terminal: set label '$a\to\infty$'

In gnuplot, how do I place the key some distance from the border?

How can I place the key some distance from a given border? For instance if I run set key below I can place the key below the graph, but it's too close and actually overlaps the xlabel. How can I place it some distance further, something like set key below 1 to put it 1 below the default below position?
To clarify, I know I can place it manually with set key at x,y, but that involves manually looking for the right place. This requires manual calculation and adjustment to, for example, get it centered. I just want to put it a bit below its default below position.
You could add a little extra height to the legend so that there is effectively more space between the bottom border of the plot and the legend content:
set key below height 2
set xlabel "this is the x axis label"
plot sin(x)
gives

Gnuplot: Unwanted white space on the left side in legend key box

Please have a look at the attached plot created from Gnuplot. I am facing two issues with it.
1) The empty white space in the left side of the key box (legend box). Is there any way to remove that extra empty white space? Neither I want to lose the key box nor compromise on the Greek letters used. Also, note that final output format has to be eps.
2) There is also too much space between the y-axis and the y-label. How to optimize it?
Please help.
Gnuplot_Image
Gnuplot doesn't know the exact width and height of the ultimately formatted strings. It rather tries to approximate the width based on some font information. That does also happen when using e.g. the qt terminal with a title containing only very narrow letters:
set terminal qt
set key box
plot x title 'iiiiiiiiiii'
That becomes even more complictated when TeX strings are involved. Use the width parameter for set key with a narrow value to decrease the key's width. You must manually estimate the actual value to use:
set terminal qt
set key box width -6
plot x title 'iiiiiiiiiii'
The same argumentation applies to the positioning of xlabel and ylabel. Here, you must use the offset parameter to correct the position:
set xlabel 'xlabel' offset 0, -0.5
set ylabel 'ylabel' offset 0.5, 0

Editing y axis range in Gnuplot

I have a plot with exponential y axis range. I'm using multiplot command by inserting two images in one row. So due to this wide y axis range I'm loosing some space which I could use it to show my plots in a better way. I want basically something like this
How could i do this? I think for doing this I have do some math operations in the y axis range. Also what is the most convenient command to insert ( xE-10) at top left of the plot.
reset
set terminal epslatex size 16cm,18cm color colortext
set output new.tex
set key off
set format $%g$
set title "sinx"
set ylabel "[kNm]"
plot 1000000*sin(x)
This is not my exact code but it looks similar to this. The plot I have presented is a part of the multiplot code and I use 7 input files with time series data of 300 seconds at a time step of 0.02. The point I want to edit the y axis range (use some mathtematical expressions) and also include the term ( xE-10 ) on the top of the plot something like this
You can manually add the exponent with a set label .... For instance, the following function takes large values within the given interval:
plot[0:50] exp(x)
We can place the "x 10^21" manually in the desired place after dividing the plotted quantity by it:
set label 1 "{/Symbol \264} 10^{21}" at graph 0,1.025 left
plot[0:50] exp(x)/1e21
You have to be careful with the exact placement of the exponent since it might lie outside the plotting area, in which case you should lower the top margin with set tmargin .... Also, to use the "times" symbol, you need to pass the enhanced option to your terminal. With the epslatex terminal, you can use latex syntax: $\times 10^{21}$.

Resources