Tutorial or Example (or Tutorial) of Using Canvas to Produce a Plot

W

W. Watson

I'm looking for an example with canvas that produces, say, a complete x-y
plot of some data. By that I mean, it should do something like the following:

1. Produce x-y axes. The x-axis should be blue and the y-axis
should be green
2. Put a label on each axis (vertical and horizontal text)
3. Plot some data (3 points is enough) and connect the points
with a dashed line. Color one line red and the other green.
4. Position a title at some arbitrary place inside the x-y axes.
That is, not just a title above and outside the top of the
x-y area.

I just want to see how it's done. I'm not interested in a full-blown canned
class or widget that does an x-y plot given some data. If not exactly the
above, then something like it that gives me some idea of how to do such a
graph. Maybe there's a tutorial that does something like this as an example.
 
W

W. Watson

What would be appropriate? What are the choices? I'm pretty new to Python,
but am familiar with the XWindow widget set. I think it is available under
Python, but if there's a more suitable choice, that's fine. I would think
Tkinter would be the simplest choice. Yes, Tkinter would be preferable. It
seems to be the GUI of choice.
 
K

kyosohma

What would be appropriate? What are the choices? I'm pretty new to Python,
but am familiar with the XWindow widget set. I think it is available under
Python, but if there's a more suitable choice, that's fine. I would think
Tkinter would be the simplest choice. Yes, Tkinter would be preferable. It
seems to be the GUI of choice.

I've heard a lot about drawing with the wxPython widget set as well.

Some examples:

http://wiki.wxpython.org/RecipesImagesAndGraphics

Mike
 
G

Grant Edwards

What would be appropriate? What are the choices? I'm pretty new to Python,
but am familiar with the XWindow widget set.

There's no such thing as "the XWindow widget set". There are
at least 8-10 different X Windows widget sets. The ones that I
can name off the top of my head:

Tk
Athena
Motif
FLTK
GTK
Qt
XRT
WxWidgets (actually sort of meta-widget-set)

http://en.wikipedia.org/wiki/Widget_toolkit

http://en.wikipedia.org/wiki/List_of_widget_toolkits#On_Unix.2C_under_the_X_Window_System
 
W

W. Watson

Thanks. I've arranged for an inter-library loan(ILL), and probably will not
get his book for several days yet. I've had the book before, but was really
unable to get the time to pursue it (the ILL). I have his web site
bookmarked. I do not yet plan to buy his book, web or hardbound yet. Maybe I
can re-examine his site for examples, and find one that is appropriate.
 
E

exhuma.twn

John Grayson's book 'Python and Tkinter Programming' has a chapter on
plotting Graphs and Charts. You can even download that chapter as a
PDF file:

http://www.manning-source.com/books/grayson/grayson_ch11.pdf

Seehttp://www.manning.com/grayson/for more info about the book.

Also, if the graph is really all you need, matplotlib might be a very
interesting choice:
http://matplotlib.sourceforge.net/

It's got some user-interface facilities as well. But I never used
those so far.
 
W

W. Watson

I'm just trying to get some feel for how canvas works. I'm about to modify a
program I use for meteor work. It uses canvas to display images, and I plan
to draw on the image. For example, I plan to draw compass headings on a
circle every 30 degrees. Just warming up to the task.
 
H

Hendrik van Rooyen

I'm just trying to get some feel for how canvas works. I'm about to modify a
program I use for meteor work. It uses canvas to display images, and I plan
to draw on the image. For example, I plan to draw compass headings on a
circle every 30 degrees. Just warming up to the task.

Don't be surprised if you can't draw a full circle - I have never managed it,
but 359.99 degrees works fine

- Hendrik
 
W

W. Watson

That's odd; however, it's likely close enough.
Don't be surprised if you can't draw a full circle - I have never managed it,
but 359.99 degrees works fine

- Hendrik
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top