I have to plot three implicit functions using gnuplot, I use this:
set contour
set cntrparam levels discrete 0
set view map
unset surface
set isosamples 1000,1000
set xrange [-5:7]
set yrange [-15:15]
set xlabel "x"
set ylabel "y"
splot y**2-x**3+15*x-13 t "t1", y**2-x**3+15*x-sqrt(4.*15.**3/27.) t "singular", y**2-x**3+15*x-30 t "t2", y**2-x**3+15*x-13 t "t3"
And the output is this:
The program is writing the 0 of the level of the surface in the legend but I just want the title parameter passed to the splot command. As the three surfaces are actually the same at a different height, I could change set cntrparam... line to draw the three of them, but what I want to do is to remove the numbers and make it write just text. How can I do that?
You cannot directly manipulate the contour level labels with any text. Just write out the contoured data to a temporary file using set table... and then plot this data file as usual. Here, you can now distinguish between different contour levels using index:
set contour
set cntrparam levels discrete 0
set view map
unset surface
set isosamples 1000,1000
set xrange \[-5:7\]
set yrange \[-15:15\]
set xlabel "x"
set ylabel "y"
set table 'contour.dat'
splot y**2-x**3+15*x-13 t "t1", y**2-x**3+15*x-sqrt(4.*15.**3/27.) t "singular", y**2-x**3+15*x-30 t "t2", y**2-x**3+15*x-13 t "t3"
unset table
set style data lines
plot 'contour.dat' index 0 title 't1', '' index 1 title 'singular', '' index 2 title 't2', '' index 3 title 't3'
Related
When plotting an X,Y,Z data set as color map I need to smoothen the plot a bit. The data are sparse and I need some sort of gaussian blur applied to the result.
Using following code :
reset
#set zrange [2:6]
set contour
unset surface
set cntrparam levels incr 2.0,0.5,8.0
set view map
set xrange [0:2184]
set yrange [0:1472]
set dgrid3d 100,100,4
set table "ap130_base_contour.txt"
splot 'ap130_base.dat' using 11:12:14
unset table
unset contour
set surface
set table "ap130_base_dgrid.txt"
splot 'ap130_base.dat' using 11:12:14
unset table
reset
set pm3d map
unset key
set palette defined (0 '#352a87', 1 '#0363e1',2 '#1485d4', 3 '#06a7c6', 4 '#38b99e', 5 '#92bf73', 6 '#d9ba56', 7 '#fcce2e', 8 '#f9fb0e')
set autoscale fix
set grid
set terminal png size 2184,1472 enhanced font "Helvetica,20"
set output 'ap130_base.png'
splot 'ap130_base_dgrid.txt' w pm3d, 'ap130_base_contour.txt' w l lc rgb "black"
set output
set terminal X11
The plot looks like this;
Is there a way to make this less 'spotty'?
Your input is much appreciated.
Gert.
Following the great info on splot pm3d I want to create two color / contour plots with same color range.
Below code creates two plots. The way the data comes in the first data set has z-data 2.0 to 5.5. The second 1.5 to 5.5. I would like both plots to use and show the same color key scale for both for better comparison. (i.e. 2 to 6)
I tried using zrange but it did not work.
#- BASE ---------------------------------------------
reset
#set zrange [2:6]
set contour
unset surface
set cntrparam levels incr 2.0,0.5,8.0
set view map
set xrange [0:2184]
set yrange [0:1472]
set dgrid3d 100,100,4
set table "ap130_base_contour.txt"
splot 'ap130_base.dat' using 11:12:14
unset table
unset contour
set surface
set table "ap130_base_dgrid.txt"
splot 'ap130_base.dat' using 11:12:14
unset table
reset
set pm3d map
unset key
set palette defined (0 '#352a87', 1 '#0363e1',2 '#1485d4', 3 '#06a7c6', 4 '#38b99e', 5 '#92bf73', 6 '#d9ba56', 7 '#fcce2e', 8 '#f9fb0e')
set autoscale fix
set grid
set terminal png size 2184,1472 enhanced font "Helvetica,20"
set output 'ap130_base.png'
splot 'ap130_base_dgrid.txt' w pm3d, 'ap130_base_contour.txt' w l lc rgb "black"
set output
set terminal X11
#- TSFF ---------------------------------------------
reset
#set zrange [2:6]
set contour
unset surface
set cntrparam levels incr 2.0,0.5,8.0
set view map
set xrange [0:2184]
set yrange [0:1472]
set dgrid3d 100,100,4
set table "ap130_tsff_contour.txt"
splot 'ap130_tsff.dat' using 11:12:14
unset table
unset contour
set surface
set table "ap130_tsff_dgrid.txt"
splot 'ap130_tsff.dat' using 11:12:14
unset table
reset
set pm3d map
unset key
set palette defined (0 '#352a87', 1 '#0363e1',2 '#1485d4', 3 '#06a7c6', 4 '#38b99e', 5 '#92bf73', 6 '#d9ba56', 7 '#fcce2e', 8 '#f9fb0e')
set autoscale fix
set grid
set terminal png size 2184,1472 enhanced font "Helvetica,20"
set output 'ap130_tsff.png'
splot 'ap130_tsff_dgrid.txt' w pm3d, 'ap130_tsff_contour.txt' w l lc rgb "black"
set output
set terminal X11
Note the color scale i the first plot from 2.0 to 5.5
In the second plot from 1.5 to 5.5
I would like both plots to have a color scale from i.e. 1 to 6.
Your input is appreciated.
Gert
Try
set zrange[2:6]
set cbrange[2:6]
It should do the trick.
I have problems changing the font size of my ytics (xtics as well) in an epslatex gnuplot.
I tried set format y '\tiny{%g}'
It is only working for the first of the two plots.
This is my code:
set terminal epslatex
set output "w_alt_nsyB_multi.tex"
set multiplot layout 1,1
set xrange [-0.5:17]
set yrange [0:110]
set xlabel "days"
set ylabel "Survival (\\%)" offset 2.5
set key reverse
set xtics font 'Arial,4' s
et style histogram errorbars gap 2 lw 1
set style data histogram
set style fill solid 1 border lt -1
set boxwidth 0.8
plot 'w_alt_nsyB.dat' every ::::7 using 2:3:xticlabels(1) title 'w1118' lt rgb "#000000",\
'w_alt_nsyB.dat' every ::::7 using 4:5 title 'wtSYN' lt rgb "#FF0000",\
'w_alt_elav_endoG.dat' every ::::7 using 6:7 title '38085' lt rgb "#9400D3"
set origin 0.5, 0.25
set size 0.5, 0.5
set xrange [-0.5:6]
set yrange [0:110]
set xlabel "\\tiny{Time of $Mn^{2+}$ treatment}"
set ytics ('10'10,'50'50,'100'100) nomirror
unset border
set xtics nomirror
unset ylabel
unset key
plot 'w_alt_nsyB_100.dat' using 2:3:xticlabels(1) lt rgb "#000000",\
'w_alt_nsyB_100.dat' using 4:5:xticlabels(1) lt rgb "#FF0000",\
'w_alt_nsyB_100.dat' using 6:7:xticlabels(1) lt rgb "#9400D3"
unset multiplot
Can anyone help me please?
The format given in set format ... isn't applied if you give an explicit manual label like you do with
set ytics ('10'10,'50'50,'100'100)
You must either just give the locations of the labels
set format y '\tiny %g'
set ytics (10, 50, 100)
or include the font macro in every manual label
set ytics ('\tiny 10' 10, '\tiny 50' 50, '\tiny 100' 100)
Note also, that your syntax \tiny{%g} is wrong, \tiny is only a switch and doesn't take any arguments. In this case it doesn't matter, because every label is wrapped in an individual LaTeX box, but in other situations it makes a big difference. To wrap the tiny font you would usually need {\tiny %g}.
The same happens for the explicit labels which are set with xticlabel. Also here, the format from set format x doesn't apply. Instead of giving a column number to xticlabel (like xticlabel(1) in your example), you must give the complete label string including the macro:
xl(c) = sprintf('\tiny %s', strcol(c))
plot 'file.dat' using 2:3:xticlabel(xl(1))
Next time, please give a minimal example which allows others to reproduce your problem. We don't have your data files to run the script. And your problem isn't related to you specific data file, so you can as well construct an example using functions, which possibly leads you itself to the solution...
I'd like to show the values of a function of 2 variables, say x+y, as a "bitmap" image. So I tried this, based on http://gnuplot.sourceforge.net/demo/heatmaps.html:
# Color runs from white to green
set palette rgbformula -7,2,-7
set cbrange [-5:5]
set cblabel "Value"
unset cbtics
set xrange [-4.5:4.5]
set yrange [-4.5:4.5]
set view map
splot x+y with image
... but I get nothing:
$ gnuplot -persist test.gp
"test.gp", line 45: warning: Image grid must be at least 2 x 2.
So how can I get the "pixel" at, say, x=-2, y=-2 to be colored according to x+y=-4 on the cbrange?
Edit: got that:
set palette rgbformula -7,2,-7
set cbrange [-5:5]
set cblabel "Value"
unset cbtics
set xrange [-4.5:4.5]
set yrange [-4.5:4.5]
set pm3d
unset surface
set view map
splot x+y
Outputs:
But - say I want the gradient in this range, exported as "smooth" gradient (no axes, ticks, marks of any kind) on a big PNG, say 3000x2000 pixels; what would be the best way to achieve that?
Starting from your edit: You just to deactivate every thing. Meaning:
unset colorbox
unset xtics
unset ytics
set border 0
Then id you create the command list:
set palette rgbformula -7,2,-7
set cbrange [-5:5]
unset cblabel
unset cbtics
set xrange [-4.5:4.5]
set yrange [-4.5:4.5]
set pm3d
unset surface
set view map
unset colorbox
unset xtics
unset ytics
set border 0
splot x+y
You get only the gradient
EDIT: In order to improve the gradient step and create a smoother image you need to use pm3d's interpolate.
set pm3d interpolate 4,4
I want the below desired effect
I am using a gnuplot script similar to this
reset
set term postscript eps enhanced "Helvetica" 30
set size square
set xlabel "X position"
set ylabel "Y position"
set pm3d map
set palette rgbformulae 22,13,-31
set xrange [0 : 22.0000000000]
set yrange [0 : 17.0000000000]
set zrange [0 : 0.1614027105]
set xtics 5
set ytics 0,4
set cbtics 0,0.020
set style line 1 lw 1
unset key
set dgrid3d 45,45
set style line 1 lt 1
set hidden3d
splot "data.data" u 1:2:3
set label "98.8" at 9,-2 textcolor lt 1
set label "1.2" at 9,6 textcolor lt 1
But when I do, the labels (98.8, and 1.2) don't get printed. If I provide a bogus data.data file, lets say with only a single (x,y,z) point, then nothing gets graphed and I can see the labels. Therefore, I am guessing that my graph is occluding my labels. How do I get the labels to be printed on top of my graph?
The default placement for labels is in back.
But you can specify that the label show up in front, e.g.:
set label "label in front" at 2.5,0.5 tc rgb "white" font ",30" front
Credit: the (very slightly modified) code for this was found at http://gnuplot.sourceforge.net/demo_svg_4.5/pm3dcolors.html and/or link(s) therefrom.
Also for further information on the placement of text in gnuplot, I found this reference to be very useful.