How to Create a 2-D Contour Plot with Labels Using Gnuplot?

AI Thread Summary
To create a 2D contour plot in gnuplot from a file with three columns (X, Y, and magnitude), the basic commands include setting the contour base, unsetting surface plotting, and using the splot command. If the data is not in grid form, users can check if it can be converted into a grid using the "dgrid3d" command. For numerical labels on the contours, additional techniques are required, as gnuplot typically generates a key mapping for contour values rather than printing them directly on the plot. Users are encouraged to explore the "help grid_data" and "help dgrid3d" commands for further assistance in managing their data format.
hamidamini
Messages
2
Reaction score
0
Hello
with gnuplot
I need to have 2d contour plot from a file (say ss.dat) with three column, first and secend columns are X and Y respectively and the third column is magnitude (I need to have this magnitude with labels on it in 2d plot).

Thanks in advance
Hamid
 
Physics news on Phys.org
Assuming your file contains grid data, the basic commands to generate a contour plot would be

set contour base
unset sur
set view map
splot 'file'

gnuplot will generate a key mapping dash patterns in the contours to values. If you want actual numerical labels printed on the contours, you have to resort to tricks. I describe one way to do it in the gnuplot Cookbook.
 
Thank you very much. my file dose not have grid data. it just has three coulmn first is "x"axis second "y" and third is just the data I want to have the plot of. How can I grid x and y axis.

Thanks
 
Your data might already be in grid form, depending on how it is organized. Type "help grid_data" at the gnuplot interactive prompt to find out what this means. Even if it is not, the plot might work. Try it and see. If your data is scattered you might be able to plot it after letting gnuplot convert it into a grid arrangement. Type "help dgrid3d" to find out how to do this.
 

Similar threads

Back
Top