I already have a nice 3D plot, with only contour projection from a data file. And I want to add a simple function on it. How can I do this?
here the code:
set autoscale
set terminal png
set contour
set output 'Corrugation_uwtp_HorizontalWind.png'
set pm3d map
set samples 50; set isosamples 50
unset key
set palette rgbformulae 33,13,10
set xlabel "Horizontal distance"
set ylabel "Vertical height"
splot "CORRUGATION_C_UWTP.dat" u 1:2:3
and I want to add following functin:
h(x)=sin(x)
Thank you for your help
Not possible directly, you have to make it in three steps, as 2D plot:
1st plot the contour to a table:
set contour; unset surface
set table $datatable
splot dataf
unset table
2nd plot the contours and your function
plot for [i=0:5] $datatable index i, f(x)
3rd plot the datafile as a coloured surface
replot dataf with image
If you use a gnuplot version prior to 5.0, you have to plot the table output to a temporary file instead of $tablename.
Related
my gnuplot script plot bar graphs in the following 2D format:
using the following sctipt:
set term pngcairo size 800,600
set termoption noenhanced
set title "$file_name" font "Century,22" textcolor "#b8860b"
set tics font "Helvetica,10"
#set xtics noenhanced
set ylabel "Fraction, %"
set xlabel "H-bond donor/aceptor, residue"
set yrange [0:1]
set ytics 0.1
set grid y
set key off
set boxwidth 0.9
set style fill solid 0.5
plot '<cat' using 2:xtic(1) with boxes
In order to add values above the bars, I've tried to modify it to
plot '<cat' using 0:2:xtic(1) with boxes, '' u 0:2:2 w labels offset 0,1
but the values were not added to the bars, with the following warning
"/dev/fd/63" line 17: warning: Skipping data file with no valid points
I can only test for Windows, but I assume cat under Linux is the equivalent for type under Windows.
So, what is your filename? I would say your filename is simply missing. Check help piped-data.
Something like the following should work:
plot '<cat myDataFile.dat' using 0:2:xtic(1) with boxes, '' u 0:2:2 w labels offset 0,1
But then, what is the difference to using directly the filename?
plot 'myDataFile.dat' using 0:2:xtic(1) with boxes, '' u 0:2:2 w labels offset 0,1
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.
I am trying to plot some experimental data points (defined by x, y, and z) and and some "iso-z" lines. To plot contour lines, the data need to be in a grid format. I tried to follow proposed elsewhere, where by means of dgrid3d the experimental, nongrid data, are converted by interpolation into grid points, and use these new data points to draw the contour lines.
The script looks as follows:
reset
set term pdf color enhanced font 'Arial, 18' size 13.5cm,9.2cm
set out 'phasediag.pdf'
#Here I convert the data points, stored in 1f.dat into a grid format.
set table '1f-grid.dat'
set dgrid3d 50,50
splot '1f.dat' u 3:4:2
unset table
#Here I would like to draw the countour lines, to be used after in the plot.
set contour base
set cntrparam level auto 5
unset surface
set table 'cont.dat'
splot '1f-grid.dat'
unset table
# Load the palette color definition.
load 'parula.pal'
set logscale cb
set cbrange[1e5:1e9]
set format cb '10^{%1.1T}'
set cblabel 'Mw / g mol^{-1}' offset 2.5,0
set format x '%1.1f'
set format y '%1.1f'
set label '1{/Symbol F}' at 0.4,6.3
set label '2{/Symbol F}' at 2.15,3
plot[0:2.7][2.5:7] '1f.dat' u 3:4:2 with points pt 5 palette, '2f.dat' u 3:2 with points pt 7 lc rgb "black"
set out
Unfortunately, I get the following error when I try to draw the contour lines in the cont.dat file:
Warning: Cannot contour non grid data. Please use "set dgrid3d".
The error surprises me a bit, as the data produced in the first where produced using dgrid3d and are in grid format.
By commentig out the section in which the contour lines should have been drown, I get the following output:
I would simply draw some lines at constant z-values. Any hint for that?
Thanks in advance,
Leo
I set-up a multiplot like this:
set terminal wxt size 1500,900
set format x "%d%m%y %H:%M:%S"
set xdata time
set timefmt x "%Y%m%dT%H%M%S"
set key font ",6"
set lmargin 10
set rmargin 10
set multiplot layout 2,1
plot "output.txt" u 1:2 w lines axes x1y1, \
"output.txt" u 1:3 w lines axes x1y2
plot "output.txt" u 1:40 w lines axes x1y1, \
"output.txt" u 1:39 w lines axes x1y2
set y2tics border
unset multiplot
Which works, and gives me 2 plots, one above the other.
But pressing the "replot" button (or using zoom) causes the second plot to fill the window - completely hiding the first plot.
Yes, that's how replot behaves. The documentation says: „Note that in multiplot mode, replot can only reproduce the most recent component plot, not the full set.“.
So, what you can do is to put the whole set multiplot ... unset multiplot stuff in an external file, load it, and then load it again. Or put that stuff in a string and eval it several times.
I had the same issue. Solved it with a loop:
set term wxt enh
do for [IDX = 0:1] {
if (IDX==1) {
set terminal png enhanced
set output 'temp.png'
}
set multiplot
set size 1,1
set origin 0,0
plot sin(x)
set size 0.5,0.35
set origin 0.13,0.63
plot cos(x)
unset multiplot
}
set output
set term wxt enh
Here is another workaround. It does not answer the question directly, but it could give idea to other similar issues. Put header, and a footer 'reread', then two context could be choosen for a similar multiplot (done twice)
if (exists("rehearse")) rehearse=1+rehearse; set term x11
if (!exists("rehearse")) rehearse=0; set term png; set output sprintf("test_palette_%s.png", system("date +\"%F\""))
pr "rehearse=".rehearse; show term #<= comment printing
set samples 100; set isosample 100,100
set xrange [0:1]; set yrange [0:1]
set palette defined (0 "white", 1 "red")
set autoscale cbfix; unset colorbox; unset key
set multiplot layout 2,2
plot '++' using 1:2:1 with image
plot '++' using 1:2:2 with image
plot '++' using 1:2:(-$1) with image
plot '++' using 1:2:(-$2) with image
unset multiplot
if(rehearse < 1) reread
Is it possible to do this with gnuplot? Something like on this image (link)
http://i.stack.imgur.com/mZ3M0.gif
I cannot seem to be able to set x = sin(y) and z = sin(y) independently. seeking help!
Thank you!
Yes! You're in luck, I figured this out last week. Here is the gnuplot code I use:
#!/usr/bin/env gnuplot
reset
set term png lw 2
set out 'test.png'
set style data lines
# Set x,y,z ranges
set xr [0:10]
set yr [-2:2]
set zr [-2:2]
# Rotates so that plots have a nice orientation.
# To get parameters, plot in interactive terminal and use 'show view' command.
set view 45,30,1,1
set arrow from 0,0,0 to 10,0,0
unset border
unset tics
splot '+' u 1:(0):(sin($1)) t 'E', \
'+' u 1:(-sin($1)):(0) t 'B'
And here is the figure I get:
I don't have labels, but you can use set label and more arrows to reproduce your example.
You can also define curves like this parametrically:
set parametric
splot u,0,sin(u) title 'E',\
u,-sin(u),0 title 'B'
Note that the u here isn't shorthand for using as you'll often see. u is a dummy variable used in parametric "s"plotting by gnuplot.