Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Help with Histograms and 3D plots

  • crux

      I have used gnuplot for a few years and have found it the best program to plot a large volume of data that is produced by my research.  I would like to create a three dimensional plot where the x-axis is angle phi, the y-axis is angle psi, and the z-axis a histogram that represents the population of "families" that these angles adopt.  I not fluent enough with gnuplot to know how to do this and would appreciate help setting up the input file.  Below is a sample of the reference data that I would use.  I would like to use histogram bins of 5 degrees.

    1.00 -63.389911 -41.634018
    2.00 -61.357625 -46.117055
    3.00 -49.001990 -30.585896
    4.00 -60.976177 -41.166163
    5.00 -83.957434 -61.084901
    6.00 -84.427957 -72.675163
    7.00 -101.947993 -67.221333
    8.00 -114.772436 -67.056555
    9.00 -112.408929 -59.562507
    10.00 -77.370395 -56.076939

    The first column is an index representing time and is unimportant for this graph.  The second and third column are phi and psi respectively.  In this data set, you will notice that two families are formed, one with angles of approx -60/-45 (7 members) and a second with angles of approx -105/-63 (3 members).

    Thanks so much in advance for help.  I have been struggling to do this for sometime now.


    • This should be considered as two separate tasks you need to complete to get a plot:

      1) you have to turn your cloud of data into a histogram.  For 1D data, gnuplot offers a 'smooth' operator that can help with this job.  For 2D data like yours, you're on your own.

      2) Only after you have a histogram, in a suitable form (see 'help glossary' and 'help datafile', pay attention to 'grid structure'), you can go ahead plotting that in gnuplot.  Types of plot you should try include:

          splot 'data' with lines
          splot 'data' with impulses
          set view map ; splot 'data' with pm3d

    • crux

      Thanks for your advice.  I think I will have to create a script to do the histogram and then plot it as a normal graph.