Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Point plotting

by BernieC (Monk)
on Mar 17, 2021 at 17:59 UTC ( #11129837=perlquestion: print w/replies, xml ) Need Help??

BernieC has asked for the wisdom of the Perl Monks concerning the following question:

I've had great success doing line-drawing with SVG {thanks for the advice and help! :o)}. Now I'm working on a slight different problem -- I want to do an incremental solution to some complicated differential equations. Might be tens of thousand of points to plot and since SVG doesn't support a "point" directly, I could do it with one-pixel-long lines, but I'm thinking there must be better graphics environments for doing that.

I've been skimming "Graphics programming in Perl" and it mentioned a lot of graphics-machinery available: GD: Image::Magick, GNUplot, PGplot, etc. Any recommendations on which might be a reasonable choice? Thanks!

Replies are listed 'Best First'.
Re: Point plotting
by hippo (Chancellor) on Mar 17, 2021 at 19:50 UTC

    In your shoes I would start with gnuplot. It is very easy for Perl to produce an output data set which gnuplot can use (a CSV of rows of x,y will be fine) and it will happily plot a sequence of disconnected points. There are a bunch of Perl modules to incorporate the plotting into your script if that is a requirement. If you subsequently want something a bit prettier (subjective) then you can look at other options.


    🦛

      I'll check out gnuplot. The only problem with using a text-coordinate file is that I'm likely to have hundreds of thousands of points. Gonna be a big file :)
Re: Point plotting -- GD and Prima
by Discipulus (Abbot) on Mar 17, 2021 at 21:16 UTC
    Hello BernieC,

    I'm absolutely not an expert, but I recently used GD and it offers $image->setPixel($x,$y,$color) that seems what you are looking for.

    I had not good experience in the past with Image::Magick because was nearly impossible to install correctly under windows, so I cant say anything about it.

    Being a GUI programmer (not a professional, only sometimes) I have always the temptetion to use Prima: it ships with Prima::Drawable which has the pixel method. See a huge, recent guide by the author at prima.eu.org. This project wa connected (same author, same site) with the IPA - Image Processing Algorithms you can find interesting.

    I will be glad to see your progresses so, if you have the time, please share them :)

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      I noticed that GD has "setpixel". When I was SVG hacking I just made a big-enough "canvas" and it all worked fine, I was thinking I could do that same with GD: give it, say, a 1000x1000 canvas and then use setPixel to do the "drawing" Thanks!
Re: Point plotting
by bliako (Prior) on Mar 18, 2021 at 00:06 UTC
    tens of thousand of points to plot

    That probably calls for raster/pixel graphics?

    In which case you start with a PNG image, and throw points at it. There is no limit to the number of points you can draw. It's easy to do it from scratch using, say, GD. Perhaps it can support opacity, antialiasing etc. to make it look nice.

    However, if you need to draw axes, labels+legends+fonts and support scaling+rotation+viewports then you need something higher level. gnuplot saved me lots of times but it has its limitations. There is also R which is state-of-the-art but put your boots on because there is a steep slope to climb and its Perl integration is minimal. But it's completely script-driven so you can create the R scripts from Perl and system() them out.

    bw, bliako

Re: Point plotting
by LanX (Cardinal) on Mar 17, 2021 at 19:43 UTC
Re: Point plotting
by Anonymous Monk on Mar 17, 2021 at 19:00 UTC
    To clarify: none of the points are to be connected? And, you have a hard requirement to produce the output as SVG?
      Not at all -- I only mentioned that I have *used* SVG before and it doesn't seem really suitable for separated points and I'm wondering which better graphics package would make sense

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11129837]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2021-06-13 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (58 votes). Check out past polls.

    Notices?