Best way to use Python to make 2d XY scatter graphs? Will TKinter do it?

Discussion in 'Python' started by rhmd, Oct 20, 2003.

  1. rhmd

    rhmd Guest

    I need to create image files (eg bmp or jpeg) of xy scatter graphs
    (i.e., graphs in which markers denote individual points; the markers
    need to be small polygons of various sizes, shapes, colors, shadings,
    etc. and there are thousands on them on each graph). Have been using
    MS Excel, but its limitations are unbelievable (only whole number
    sizes, no way around a 56 color palette, only low quality jpeg files
    so that when I publish the graphs I have to print and scan them all to
    get a decent image, no more than 32K markers in a single series).
    From a programming point of view, Python is perfect to set up
    something like this, but MY QUESTION IS: Will TKinter do this? Or
    will it be necessary to learn OpenGL? Or is another Python compatible
    package best? Thanks for your help.
    rhmd, Oct 20, 2003
    1. Advertisements

  2. rhmd

    Chris Lyon Guest

    Sounds like a job for PIL.
    Chris Lyon, Oct 20, 2003
    1. Advertisements

  3. rhmd

    Dean Guest

    What you want is the magic of Blt graph available through the Pmw
    package (or write your on Tkinter like wrapper). If you can imagine
    it this graphing package can to it (with a little bit of work and know
    how). The only snag is that image output as far as I know is limited
    to gif out of the box. I beleive with a little bit of work you will
    be able to get jpeg output.

    The second link is the most useful.

    Dean, Oct 20, 2003
  4. rhmd

    Duncan Smith Guest

    I use Dislin for this sort of thing

    Duncan Smith, Oct 20, 2003
  5. rhmd

    Miki Tebeka Guest

    Miki Tebeka, Oct 20, 2003
  6. rhmd

    enoch Guest

    Since this hasn't been mentioned, there's a gnuplot binding for
    python. I have used it successfully and without any speed problems for
    scatter plots with > 20000 points, and it gives you the added benefit
    to play around with the graphs in gnuplot itself.
    enoch, Oct 22, 2003
  7. rhmd

    John Hunter Guest

    rhmd> I need to create image files (eg bmp or jpeg) of xy scatter
    rhmd> graphs (i.e., graphs in which markers denote individual
    rhmd> points; the markers need to be small polygons of various
    rhmd> sizes, shapes, colors, shadings, etc. and there are
    rhmd> thousands on them on each graph).

    matplotlib makes x-y scatter plots with circles of arbitrary size and

    from matplotlib.matlab import *

    ... x, y, size, and color are Numeric arrays ...
    scatter(x, y, size, color)

    It doesn't (yet) support polygons, but this would be easy to add (I'm
    putting it on my TODO list) -- It
    has the added benefit of interactive rescaling of axes with GUI
    widgets, a postscript output, and more!

    John Hunter, Oct 22, 2003
  8. rhmd

    Stan Graves Guest

    I'll second that. Gnuplot is THE plotter to have on hand, if you can
    only have one plotter on hand...

    There is a handy tool to tie python to gnuplot...

    --Stan Graves
    Stan Graves, Oct 22, 2003
  9. (sorry, I respond to this message because I can not
    find the original message)

    You might also have a look at reportlab's graphics library.
    You can have output of your graphics as PNG, JPEG,...,
    pdf or postscript (SVG was buggy as I looked at it, I don't
    know the present state).
    There is also some beginning of charting
    library, but you can draw whatewer you like, it is IMO relatively
    easy to use. The downside for you may be that it is not
    very fast if you have a lot of objects to draw, but you may look
    if it is fast enough for you.
    Marijan Tadin, Oct 23, 2003
  10. rhmd

    Pat Bills Guest

    (rhmd) wrote in
    I would like to add a possible solution to those suggested. This may be
    off-topic and I don't know the context of the question. I, too,
    abandoned Excel as my graphing platform.

    If you are automating research processes and not writing software for
    distribution then I think the R environment ( is
    worth a look. I've used it for several research projects and created
    graphs for publication. There are Python packages to call R from python,
    although complete programs can be written in R, which to my newbie eyes
    is very Python-like. The graphs can written to several formats (see
    below) and can paste into your favorite word/presentation processor.

    The added bonus is you get a wealth of statistical processes along with
    plotting (although you didn't mention this requirement in your post).

    There are several downsides: your program would require R to be installed
    on the system; batching R on windows does not work (for me); there is a
    learning curve; and parameters are a bit quirky (work like globals).

    description from the R site:
    R is a language and environment for statistical computing and graphics.
    It is a GNU project which is similar to the S language and environment...
    One of R's strengths is the ease with which well-designed publication-
    quality plots can be produced, including mathematical symbols and
    formulae where needed.

    from the R help:
    The following graphics devices are currently available:

    * `postscript' Writes PostScript graphics commands to a file

    * `pdf' Write PDF graphics commands to a file

    * `pictex' Writes LaTeX/PicTeX graphics commands to a file

    * `windows' The graphics driver for Windows (on screen, to
    printer and to Windows metafile).

    * `png' PNG bitmap device

    * `jpeg' JPEG bitmap device

    * `bmp' BMP bitmap device

    * `xfig' Device for XFIG graphics file format

    * `bitmap' bitmap pseudo-device via `GhostScript' (if
    Pat Bills, Oct 27, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.