I have a bunch of 2D points, each point comes with an error in the x coordinate and in the y coordinate. I don't like how with xyerrorbars shows the points because these are measurement that will be more and more dense.
I'd like if these points could form a colored surface, like these kind of plots:
http://www-cdf.fnal.gov/physics/new/hdg/Results_files/results/hwwmenn_120224/figures/limit/cdf4g17july2011.gif
Do you know if there's there a striagth forward way in Gnuplot?
Thanks!
I will assume that your data file is in the following format:
x y sx sy
where sx and sy are the standard deviations in x and y. You can use the filledcurves option to plot:
plot 'data.dat' using 1:($2+2*$4):($2-2*$4) title '+/- 2 SD', \
'data.dat' using 1:($2+$4):($2-$4) title '+/- 1 SD', \
'data.dat' title 'data'
help filledcurves gives you a couple of examples.
Related
I want to draw several vectors in a 3D plot. The co-ordinates of the start and end point are columns in a data file. In 2D, I plot vectors by:
plot 'data.dat' u 1:2:($3-$1):($4-$2) with vectors
How can I do it in 3D?
Edit
I am trying to draw these vectors on top of a surface. When I try this:
set hidden3d
set xlabel "x"
set ylabel "y"
set zlabel "z"
set dgrid3d 10,10 qnorm 2
file = "surface.dat"
splot file u 1:2:3 with lines, file 1:2:3:($4-$1):($5-$2):($6-$3) with vectors
I get the surface, but not the vectors. (The vectors are out of the plane of the surface, like normals.)
Have you done any search at all? Have you checked the gnuplot homepage or gnuplot documentation?
From help vectors:
`The 2D vectors style draws a vector from (x,y) to (x+xdelta,y+ydelta). The 3D vectors style is similar, but requires six columns of basic data. In both cases, an additional input column (5th in 2D, 7th in 3D) may be used to provide variable (per-datapoint) color information. (see linecolor and rgbcolor variable). A small arrowhead is drawn at the end of each vector.
4 columns: x y xdelta ydelta
6 columns: x y z xdelta ydelta zdelta
... and further down...
Example:
plot 'file.dat' using 1:2:3:4 with vectors head filled lt 2
splot 'file.dat' using 1:2:3:(1):(1):(1) with vectors filled head lw 2
Hence, depending on your columns:
splot 'data.dat' u 1:2:3:($4-$1):($5-$2):($6-$3) with vectors
I want to plot a series of points, a plane and the intersection points with that plane using gnuplot. In order to do this, I created the following gnuplot script:
set title 'Homogeneous field with plane intersection'
set xlabel 'x'
set ylabel 'y'
set zlabel 'z'
set parametric
splot 'points.txt' with linespoints, 'intersectionPoints.txt' with points
pointtype 7 lc rgb 'red',
60 + 0 * u, u, v
The script produces the following plot:
Everything works fine, however the size of the parametric plane is way too small. How can I get gnuplot to automatically adjust the size of the plane to roughly match the dimensions of the rest of the plot?
You have to set the ranges for the two parameters u and v, for example
set urange [-50:250]
set vrange [-20:20]
From help parametric: " Currently the default range for these parametric variables is [-5:5]. Setting the ranges to something more meaningful is expected.".
Using gnuplot, I am trying to make a 2D plot with points where the point color is represented by the third column of a data file(file has 3 columns)
Here is the link to the file
I am using the following command to generate the graph:
pl "outPhaseDiff_b1_dScan.dat" u 1:2:3 w p pt 7 ps 2 lc variable
The desired output should contain 5 colors but it is only plotting 2 colors, which is really strange because I have been using this command for a long time and did not encounter such issue before. I guess it has to do something with the plotting algorithm but I have no clue.
Check your data, it contains many line pairs with the following pattern:
0.0000 0.0060 3
0.0000 0.0060 5
One line with x, y, color1, another line with identical x and y, but different color2. So the points from the second line hide the points from the first one.
If you plot it 3d with several layers, it looks like this:
z = 0
y = 0
splot "outPhaseDiff_b1_dScan.dat" \
u 1:2:($2 == y ? (z = z+1) : (z = 0, y=$2), z):3 \
w p pt 7 ps 2 lc variable
A 2d plot looks from top, only two colors are visible.
I have a function z=f(x,y) and want to plot it using octave, but don't want the plot to be in 3d, as in
octave:1> x=(1:300);
octave:2> y=(1:300);
octave:3> [xx,yy]=meshgrid(x,y);
octave:4> A=sin(xx/100).*yy;
octave:5> mesh(x,y,A)
but rather in 2d using colors for the values of z, like what you get using the gnuplot instruction
gnuplot> plot 'a.txt' matrix w image
if I save the matrix A in the file a.txt. The closest I have found is the command contourf, but the as you can see if you try it,
octave:7> contourf(xx,yy,A)
the result is far from optimal... Any suggestion?
Thanks
imagesc will plot a matrix of your "z" values using colors:
> imagesc(x, y, A)
This will be inverted vertically compared to contourf, but that's easily fixed:
> imagesc(x, flipud(y), flipud(A))
And in your example you don't even need to provide the variables x and y:
> imagesc(A)
> imagesc(flipud(A))
I have a file of points (x, y) that I plot using gnuplot. If I have another file that shows which point is linked with which other point by an edge (e.g. (3.8, 6) linked to (4,7)), is it possible to visualise/plot this edges between points ?
depending on how your data is organized, you may want to look into plotting with vectors.
For example, if your datafile looks like:
#x1 y1 x2 y2
1 1 3 3
You can plot this using:
set style arrow 1 nohead
plot "my_arrows.dat" using 1:2:($3-$1):($4-$2) with vectors arrowstyle 1
EDIT
Assuming all the points in your datafile are repeated, you can do the following:
set style arrow 1 nohead
plot "my_arrows.dat" using 1:2:($3-$1):($4-$2) with vectors arrowstyle 1,\
"my_arrows.dat" using 1:2 w points
If they're not repeated, you can do:
set style arrow 1 nohead
plot "my_arrows.dat" using 1:2:($3-$1):($4-$2) with vectors arrowstyle 1,\
"my_arrows.dat" using 1:2 w points ls 1 lc rgb "red" pt 1,\
"my_arrows.dat" using 3:4 w points ls 1 lc rgb "red" pt 1
Note that you can play around with the linestyles (linecolor or lc, pointtype or pt, linewidth or lw etc. to make the points appear the same.)
You might not be able to read the line positions in without using a separate utility to generate your plotscript, but the command to draw a line from point to point is
set arrow [X] from first x1,y1 to first x2,y2 nohead
where X is an optional tag number for the arrow, and (x1,y1) and (x2,y2) are points in the graph's coordinate system.