Menu

#184 creating and plotting a histogram from file containing xyz data

None
closed
nobody
5
2015-04-21
2015-04-17
JP
No

I have successfully generated 3D and 2D plots from a large data file of pixel values, where the file is a list of xyz values in csv format with 3 columns: integer x value, integer y value, decimal z value. I would like to create a 2D histogram of only the z column now with, for example, 1000 bins from min to max value (or limits I hard code in). I don't know if this is possible as I could not find an adequate example in the demos or help text. Has someone done this already, and can you share a good example code? I don't know if I need to do this in two phases, first being to bin the values and next to plot them, or if this should be essentially a one-command operation. Thanks for any help.

I attached the first two rows of my xyz data which represents what I want to plot as a histogram.

1 Attachments

Discussion

  • Ethan Merritt

    Ethan Merritt - 2015-04-17

    See "help smooth frequency"

     
  • JP

    JP - 2015-04-18

    Hi Ethan, saw this in the help file when I jumped to the smooth.dem page:

    plot "random-points" u 2:(0.25*rand(0)-.35) t '', \ "" u (bin($2,0.05)):(20/300.) smooth freq t 'smooth frequency' w boxes, \ "" u 2:(1/300.) smooth cumulative t 'smooth cumulative'

    and this raises a whole mess of new questions, but some of the first are:
    what do u and t do? Not mentioned in help files! using and title?
    what is the $ doing?

    I will play around with this and post again if I get stuck, seems like this is the solution for me though, I just need to select column 3 within my datafile and get the scaling and binning correct.
    Thanks for the tip.

     
  • Ethan Merritt

    Ethan Merritt - 2015-04-18

    u and t are the dummy variables for a parametric function. They are not relevant to your case.

    $2 is shorthand for column(2) , i.e. the value of the 2nd column in your data file

    plot FOO using 1:2:3

    is the same as

    plot FOO using ($1):($2):($3)

    is the same as

    plot FOO using (column(1)):(column(2)):(column(3))

     
  • Ethan Merritt

    Ethan Merritt - 2015-04-21
    • status: open --> closed
    • Group: -->
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.