472,779 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

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

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.
Jul 18 '05 #1
9 6978
rh*******@juno.com (rhmd) wrote in message news:<61**************************@posting.google. com>...
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.

Sounds like a job for PIL. http://www.pythonware.com/products/pil/
Jul 18 '05 #2
rh*******@juno.com (rhmd) wrote in message news:<61**************************@posting.google. com>...
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.


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.

http://pmw.sourceforge.net/doc/index.html
http://heim.ifi.uio.no/~hpl/Pmw.Blt/doc/

The second link is the most useful.

Cheers
Jul 18 '05 #3

"rhmd" <rh*******@juno.com> wrote in message
news:61**************************@posting.google.c om...
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.


I use Dislin for this sort of thing http://www.linmpi.mpg.de/dislin/

Duncan
Jul 18 '05 #4
Hello,
Will TKinter do this? Or
will it be necessary to learn OpenGL? Or is another Python compatible
package best? Thanks for your help.

Have a look at http://www.python.org/topics/scicomp/plotting.html

I also highly recommend PIL (http://www.pythonware.com/products/pil/)

HTH.
Miki
Jul 18 '05 #5
rh*******@juno.com (rhmd) wrote in message news:<61**************************@posting.google. com>...
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.


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.
Jul 18 '05 #6
>>>>> "rhmd" == rhmd <rh*******@juno.com> writes:

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
color

from matplotlib.matlab import *

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

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

JDH

Jul 18 '05 #7
en***@gmx.net (enoch) wrote in message news:<ad**************************@posting.google. com>...
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.


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...

http://gnuplot-py.sourceforge.net/

--Stan Graves
st**@SoundInMotionDJ.com
http://www.SoundInMotionDJ.com
Jul 18 '05 #8
(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.
http://www.reportlab.org/rl_toolkit.html
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

"enoch" <en***@gmx.net> wrote in message
news:ad**************************@posting.google.c om...
rh*******@juno.com (rhmd) wrote in message

news:<61**************************@posting.google. com>...
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.


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.


Jul 18 '05 #9
rh*******@juno.com (rhmd) wrote in news:616fccba.0310200250.22d55351
@posting.google.com:
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.


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 (http://r-project.org) 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).

http://r-project.org
http://www.omegahat.org/RSPython/index.html
http://rpy.sourceforge.net/
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
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
53
by: Paul Rubin | last post by:
I've been approached about writing a Windows app which will need a really professional looking GUI. Forget TKinter, this has to actually look good (real artists will be available to get the visual...
0
by: Cameron Laird | last post by:
QOTW: "Well, to do what I've done so far in Java would have taken at least 5 and probably more like 10 times the code I've written. A simple yet decent TCP chat server in about 30 lines of code...
3
by: John Hunter | last post by:
matplotlib is a 2D plotting library for python. You can use matplotlib interactively from a python shell or IDE, or embed it in GUI applications (WX, GTK, and Tkinter). matplotlib supports many...
9
by: Dr. Colombes | last post by:
What is the easiest way to generate some plots and graphs in Python ? Specifically interested in simple histograms and scatter plots with circles and regression lines. Thanks for your...
14
by: Jeffrey Barish | last post by:
Since upgrading to python 2.4 yesterday, I am no longer able to use Tkinter. From http://www.python.org/moin/TkInter I learned that I need to edit Modules/Setup to include Tkinter during the make....
11
by: MartinRinehart | last post by:
I went to Python.org, DL'd Python 2.5 source code per the usual inadequate instructions and ran the make files successfully (sort of). Python 2.5 works fine. But "from Tkinter import *" gets a...
8
by: karthikbalaguru | last post by:
Hi, One of my python program needs tkinter to be installed to run successfully. I am using Redhat 9.0 and hence tried installing by copying the tkinter-2.2.2-36.i386.rpm alone from the CD 3 to...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.