Gnuplot countours with discrete data points and dgrid3d - gnuplot

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

Related

gnuplot: add values above bar graphs

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

Plot error_bars with lines in gnuplot

I have a file with the delivery rate of a simulation and its confidence interval. I need to plot an error bar on my chart. Need to be the line graph and also the error bar on a single chart
Sample data:
V D IC
10 99.2373 0.000200729
30 97.2515 0.00649952
60 94.6761 0.00950475
I would like it to look like the example below:
Here is my code:
set nokey
set grid
set key right inside
set xlabel 'Velocidade em Km/h'
set ylabel 'Taxa de Entrega'
set autoscale
set yr[0:100]
set style data lines
plot 'taxa_entrega-AODV-50-250.txt' using 1:2:($2-$3):($2+$3) with yerrorbars
if you are plotting errorbars you typically plot data with points but not necessarily with connected lines or linespoints. Instead you add a line described by a model or fit.
However, from the image you are referring to I assume you want to have the points nevertheless connected. So, simply add ,\ the same data '' again as lines.
plot 'taxa_entrega-AODV-50-250.txt' using 1:2:($2-$3):($2+$3) with yerrorbars,\
'' using 1:2 with lines
Addition: See below what you get with the full code. (I commented out the set yrange[0:100] because otherwise one wouldn't see too much with the data you provided. Furthermore, your errobars are in the range of 0.0002 to 0.009. Relative to the values 94.6 to 99.2, these will not be bars but more points.
reset session
set nokey
set grid
set key right inside
set xlabel 'Velocidade em Km/h'
set ylabel 'Taxa de Entrega'
set autoscale
# set yrange[0:100]
set style data lines
plot 'taxa_entrega-AODV-50-250.txt' using 1:2:($2-$3):($2+$3) with yerrorbars,\
'' using 1:2 with lines

GNUPLOT - Add a 2D curve in a 3D Contour plot

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.

Adjusting the position of countour base plane in gnuplot

I am trying to use gnuplot to plot the graphene band structure as both surfaces and a countour plot at the base, set with set contour base, but I can't get rid of some axis lines and the plane where the contour is drawn is too far away from the surfaces when I place them in the adequate viewing angle.
Here is the code to plot the graph
# Setting ranges and function parameters
set xrange [-.55:.55]
set yrange [-1:1]
t=-3.033 s=0.129 a=1.43 * sqrt(3)
# Auxiliary functions
kx(x,y) = (2*pi/a) * (cos(pi/6)*x + sin(pi/6)*y) ky(x,y) = (2*pi/a) * (cos(pi/6)*x - sin(pi/6)*y)
w(x,y) = sqrt(1+4*cos(0.5*sqrt(3)*kx(x,y)*a)*cos(0.5*a*ky(x,y)) + 4*(cos(0.5*ky(x,y)*a))**2)
#functions to be plotted
e(x,y) = (t*w(x,y))/(1+s*w(x,y))
e_estrela(x,y) = (-t*w(x,y))/(1-s*w(x,y))
# Setting up 3D plot appearance
set hidden3d
set contour base set cntrparam levels discrete 0,0.5,1,2,4,8
set view 75, 31, 0.601098, 1.4385
set isosamples 60
# Removing unwanted stuff
unset xtics
unset ytics
unset ztics
unset key
splot e_estrela(x,y), e(x,y)
And the output I get (with the pngcairo terminal, but that's not relevant, I guess) is:
Is it possible to draw the contour base plane closer to the surfaces? And how about removing those vertical black lines?
For the first part, I tried playing wioth set zrange with no success. The base plane seems to be drawn a certain z-distance below the lowest z-range limit everytime.
Ideas? Thanks in advance!
To adjust the distance between your data and the xy-plane use the option
set xyplane relative <value>
where <value> gives you the distance between the xy-plane and the minimal z-value in relative fraction of the hight of your plot. So <value>=0 sets the distance to zero, <value>=0.5 to half the hight.
To control the border use set border where each border line is represented by bits. Please refers to the documentation for more details. In your case I would suggest:
set border 127+256+512 # or set border 1023-128
set grid #forces borders from xy-plane to plot

gnuplot : 3d plot an electromagnetic wave function

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.

Resources