Text label over point gnuplot - 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$'

Related

Default weighing criterion for gnuplot's 'lc palette'

I'm a novice in Gnuplot. Today I was plotting a simple txt file with two data columns, being the x and y coordinates of a cloud of points in the xy plane; I wanted to color them according to the position they occupied in the list, so I should have gone for something like:
plot "data.txt" u 1:2:0 lc palette
that produces what I want:
(desired plot)
By mistake, I omitted the "using" part of the command, so that I prompted:
plot "data.txt" lc palette
Now, the points still are plotted in the correct positions, so that gnuplot is automatically interpreting them as (x,y) coordinates... but the colors look like this:
(strangely colored plot)
I find this baffling since there's the possibility that I'm involuntarily highlighting some interesting feature of my data (which, by the way, consists of few iterations of a discrete recurrence for a set - the x=1.57 line you can see - of different initial conditions.
The question is: what criterion does 'lc palette' use to assign the parity I see to my points? What is its default behavior supposed to be in this case?
Thanks in advance!
EDIT: I don't know if it can be useful, but prompting 'show palette' I get:
palette is COLOR
rgb color mapping by rgbformulae are 7,5,15
figure is POSITIVE
all color formulae ARE NOT written into output postscript file
allocating ALL remaining color positions for discrete palette terminals
Color-Model: RGB
gamma is 1.5

gnuplot - distance between columns in a key [duplicate]

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

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}$.

Column and row name formatting in gnuplot

I prepared a code to graph my script's csv output. They are column separated values.
I used code below to do that:
#!/usr/bin/gnuplot -persist
set datafile separator ":"
set terminal png nocrop font small size 640,480
set output 'mychart.png'
set style data histograms
set title "some graph title"
set xlabel "some x asis name"
set ylabel "some ya axis name"
plot "/home/username/Desktop/test.csv" using 2:xticlabels(1) notitle
This will draw the graph successfully. However I have two problems here. One in x axis, there are big numerical values such as 50000000, 6000000 so graph shows them in exponential format such as 5E+9 6E+8. But I would like to see full number. Second, in y axis, there are almost 20 alphanumeric values (some network parameter names) and each of them with at least 25-30 character. So they won't show up properly. Is there a way to write them with a smaller font and an angle?
Thanks
To change the format of the numbers shown on the y-axis, use e.g.
set format y '%.0f'
The labels of the xtics can be rotated (rotate by 45), aligned differently (right) and they can use a different font size (font), e.g.
set xtics right rotate by 45 font ',8'
See also rotating and justifying tics in gnuplot.
You may need to adjust the bottom border to have enough space for the labels, e.g. with
set bmargin 6
BTW: You should use the pngcairo terminal (available since version 4.4), which produced much nicer graphs than the png terminal.

Resources