How to simply get contour or surface plot form datafile?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to simply get contour or surface plot form datafile?

Keccogrin
Hello,
I would like to use gnuplot to plot my 2d function ch(x,y) [obtained by a
pde solver, FreeFem++]. My datafile is structured in this way:


x1 y1 ch(x1,y1)
x2 x2 ch(x2,y2)
x3 y3 ch(x3,y3)
x1 y1 ch(x1,y1)


x4 y4 ch(x4,y4)
...
...
...


...


where I have the value of my function at the 3 vertices of every triangle
which constitutes my (triangular, not structured) mesh (see figure here
http://i65.tinypic.com/2mydkq9.jpg).
What I would like to get is two separate figures:
1. something like this for the surface, with a colorbar as a legend:
http://i68.tinypic.com/egvkzr.jpg
and
2. something like this for contour lines, with a colorbar as a legend:
http://i67.tinypic.com/msgepg.jpg


How can I get these two figures with gnuplot?
I've tried for example doing the first one :


set palette rgbformulae 33,13,10
set xrange [0: 0.25]
set yrange [0: 0.20]
set view map
splot "mydatafile.txt" w l pal


but the triangles inside are white (not filled with colors) and only the
edges of the triangles are coloured.
How about the contour lines?


Thank you in advance,


Keccogrin
------------------------------------------------------------------------------
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to simply get contour or surface plot form datafile?

theozh
although there are a few examples at
http://gnuplot.sourceforge.net/demo/

I still find it pretty confusing
about plot, splot, matrix, with image, surface plot, contour plot or
2D/3D heatmap...

Anyway, to my understanding if you have data which is not in a regular
matrix, i.e. "non-gridded data" you first need to convert the data into
a regular grid (see "set dgrid3d").
See example: non-gridded data


Maybe the following code helps you?
The file "RandomMesh.dat" consist of 3 columns with x y z data, so
similar to your data.


####### Plot arbitrary mesh data
reset

set view map
set dgrid3d 30,30,10
set palette rgbformulae 33,13,10

set multiplot layout 1,2

set surface
unset contour
splot "RandomMesh.dat" w pm3d

unset surface
set contour
set cntrparam levels 10
splot "RandomMesh.dat" w pm3d

unset multiplot
####### EOF


------------------------------------------------------------------------------
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Loading...