Line styles on gnuplot 4.4 - gnuplot

Well, I'm trying to plot this graphic:
gnuplot> plot exp(-x) t 'MB' w l lw 3, (exp(x)-1)**(-1) w l lw 3 t 'BE', (exp(x)+1)**(-1) w l lw 3 t 'FD'
and exporting with
set terminal latex
How, or what, I have to do to the graphics be plotted in different lines styles, as dotted and dashed?

In order to specify line styles check the documentation here. You can specify the line type, line color, line width, point type etc.
To specify a blue dotted line on an X11 terminal do
set style line 1 lt 0 lc 3
plot x**2 ls 1
Note that the styles also depend on the terminal you are using. To see what possibilities there are use the test page of the current terminal by running test in your gnuplot console.
Examples of different line styles can be found here and there.

Related

Gnuplot Vertical Dashed Line

I would like to add a gray dashed vertical line on my graph with GNUPLOT.
My terminal is;
set terminal postscript portrait enhanced color dashed lw 1 "DejaVuSans" 12 size 6,6
set output "pic.ps"
set xrange [30:110]
plot 'smth.txt' w lines ls 7 t ""
I have looked into several ideas around but there seems to no explanation about how to get a dashed gray line vertically at let's say x = 40 (the line gonna be parallel to y-axis)
The key is to use the set arrow command and remove the head to make it a line:
set arrow from 40,0 to 40,100 nohead lc rgb 'red' dt 2
Your graph does not specify any y value, so adjust it to a "larger than needed" value.
For dash type (dt), checkout p.42 of manual. It is terminal-dependent (I didn't tried with postscript), but you can adjust as needed.

How to make dashed grid lines intersect making crosshairs in gnuplot?

I'm plotting some data and I want to use dashed grid lines.
Any dashed grid line would suffice, but I prefer a "long dash, short dash, long dash" format.
For example, given the following code
set grid lc rgb "#000000" lt 1 dt (50, 25, 20, 25)
plot x**2
I get this result
But I would rather the grid lines intersection to happen always at the middle of two dashes, like this
If I could make horizontal grid lines different to vertical grid lines and I could add some offset to each one, then I'd imagine there's a way to accomplish this. But I can't seem to do that either.
It looks like gnuplot cannot have two different dashstyles for x-grid and y-grid.
One workaround I see currently is to plot two identical plot on top of each other. One with appropriate x-grid lines and the other with appropriate y-grid lines.
If you want a dash pattern with proportions of (50-25-20-25), this correspond to (25-25-20-25-25-0) or (5-5-4-5-5-0) between two tics.
Furthermore, the dash and gap length numbers, e.g. in dt (50,25,20,25), seem to be in a fixed relation to the graph size. The "empirical" factor is 11 with good approximation (at least for the wxt terminal which I tested under gnuplot 5.2.6).
Edit: actually, the code below gives different results with a qt terminal. And it's not just a different factor. It's more complicated and probably difficult to solve without insight into the source code. So, the fact that the following seems to work with wxt terminal (maybe even just under Windows?) was probably a lucky strike.
With this you can create your dash lines automatically resulting in crosshairs at the intersections of the major grid lines.
Assumptions are:
your first and last tics are on the borders
you know the number of x- and y-intervals
You also need to know the graph size. These values are stored in the variables GPVAL_TERM..., but only after plotting. That's why you have to replot to get the correct values.
This workaround at least should give always crosshairs at the intersection of the major grid lines.
Edit 2: just for "completeness". The factors to get the same (or similar) looking custom dashed pattern on different terminals varies considerably. wxt approx. 11, qt approx. 5.6, pngcairoapprox. 0.25. This is not what I would expect. Furthermore, it looks like the factors slightly depend on x and y as well as graph size. In order to get "exact" crosshairs you might have to tweak these numbers a little further.
Code:
### dashed grid lines with crosshairs at intersections
reset session
TERM = "wxt" # choose terminal
if (TERM eq "wxt") {
set term wxt size 800,600
FactorX = 11. # wxt
FactorY = 11. # wxt
}
if (TERM eq "qt") {
set term qt size 800,600
FactorX = 5.58 # qt
FactorY = 5.575 # qt
}
if (TERM eq "pngcairo") {
set term pngcairo size 800,600
set output "tbDashTest.png"
FactorX = 0.249 # pngcairo
FactorY = 0.251 # pngcairo
}
set multiplot
set ticscale 0,0
Units = 24 # pattern (5,5,4,5,5,0) are 24 units
# set interval and repetition parameters
IntervalsY = 10
RepetitionsY = 1
IntervalsX = 4
RepetitionsX = 3
# initial plot to get graph size
plot x**2
gX = real(GPVAL_TERM_YMAX-GPVAL_TERM_YMIN)/IntervalsY/Units/FactorY/RepetitionsY
gY = real(GPVAL_TERM_XMAX-GPVAL_TERM_XMIN)/IntervalsX/Units/FactorX/RepetitionsX
# first plot with x-grid lines
set grid xtics lt 1 lc rgb "black" dt (gX*5,gX*5,gX*4,gX*5,gX*5,0)
replot
unset grid
# second plot with y-grid lines
set grid ytics lt 1 lc rgb "black" dt (gY*5,gY*5,gY*4,gY*5,gY*5,0)
replot
unset multiplot
set output
### end of code
Result:
Not really. The closest I can think of is
set grid x y mx my
set grid lt -1 lc "black" lw 1 , lt -1 lc bgnd lw 16
set ticscale 1.0, 0.01
set mxtics 4
plot x**2 lw 2
But that leaves the vertical grid lines solid.

Gnuplot: line not recognised

I am trying to change the line style of my gnuplot graph (there is only one line, I have only a simple plot of y versus x)
However, when I type:
set style line 1 linecolor rgb '#0060ad' ... (or linewidth or whatever argument)
(& replot)
nothing happens... it seems that it doesn't recognise the plot as "line 1".. I also tried to change the line index to a different number or its name...
Could anybody please help what to put "set style ..." argument?
Thank you very much!
Gnuplot has linestyle and linetype:
set linetype 1 linecolor "yellow"
plot x
or
set style line 1 linecolor "magenta"
plot x linestyle 1
Using set linetype is the recommended way, line style is deprecated.
Note, that resetting the line type must be done with reset session (gnuplot version 5), reset alone doesn't work.

How to add symbols representing point types in y labels

I want to add the symbols representing point types to y and y2 labels.
Here is the test code:
set key center top;
set ylabel "x";
set y2label "x^2";
plot x w lp pt 5 pi 5, x**2 w lp pt 7 pi 5 axes x1y2;
It gives:
I want the following:
Is there anyway to achieve this in Gnuplot?
I am using Gnuplot 4.6.5.
Thanks.
One option would be to use set label ... point pt 7 lt 2 to place a dot somewhere. But that needs a lot of tweaking to get the correct position. And that position would need to be adapted manually depending on the font, font size, canvas size etc.
If only the point shape is important, you can use the respective glyph from the unicode block: geometric shapes. This is also from where I copied the symbols to the script. You must of course also use a font which includes the respective glyphs (e.g. Arial Unicode or DejaVu) and a proper terminal (e.g. pdfcairo, pngcairo, wxt are all fine):
set terminal pngcairo enhanced font "DejaVu" size 600,300
set output 'square-circle.png'
set key center top
set encoding utf8
set ylabel "x {/*0.8 ■}"
set y2label "x^2 {/*0.8 ●}"
plot x w lp pt 5 pi 5, x**2 w lp pt 7 pi 5 axes x1y2;
Result with 4.6.5 is:

Gnuplot vertical gradient on boxes depending of a value?

Is this possible in gnuplot?
How more energie how harder the color, look the example.
plot for [i=1:16] file u 1:($10/i):((i*2)*1048576) w boxes lc rgb variable notitle.
This is what I have now, this might be a possibility? The first example was an Excel graph.
Finaly i have for me the perfect, and . . i think a very nice solution.
First the plot and after that the correspondenting script.
The highlights are;
maks = STATS_max_y
min = STATS_max_x
afgenomen = gebruikt-zon
set palette defined (-(min) "#D30000", 0 "#00F000", .1 "#FFF900", (maks) "#FF0700")
plot for [i=51:1:-1] file u 1:(($10/51)*i):(($10/51)*i) w boxes lc palette notitle,\
file u 1:10 w boxes fill empty notitle,\
For all the examples that i have made look on my site: http://ccvd.eu/Energie.html

Resources