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

Discussion in 'Python' started by W. Watson, Sep 18, 2007.

  1. W. Watson

    W. Watson Guest

    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.

    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
     
    W. Watson, Sep 18, 2007
    #1
    1. Advertising

  2. On 2007-09-18, W. Watson <> wrote:

    > I'm looking for an example with canvas that produces, say, a
    > complete x-y plot of some data.


    With what widget set?

    --
    Grant Edwards grante Yow! I'm a nuclear
    at submarine under the
    visi.com polar ice cap and I need
    a Kleenex!
     
    Grant Edwards, Sep 18, 2007
    #2
    1. Advertising

  3. W. Watson

    W. Watson Guest

    Re: Tutorial or Example (or Tutorial) of Using Canvas to Producea Plot

    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.

    Grant Edwards wrote:
    > On 2007-09-18, W. Watson <> wrote:
    >
    >> I'm looking for an example with canvas that produces, say, a
    >> complete x-y plot of some data.

    >
    > With what widget set?
    >


    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
     
    W. Watson, Sep 18, 2007
    #3
  4. W. Watson

    Guest

    On Sep 18, 12:23 pm, "W. Watson" <> wrote:
    > 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.
    >
    > Grant Edwards wrote:
    > > On 2007-09-18, W. Watson <> wrote:

    >
    > >> I'm looking for an example with canvas that produces, say, a
    > >> complete x-y plot of some data.

    >
    > > With what widget set?

    >
    > --
    > Wayne Watson (Nevada City, CA)
    >
    > Web Page: <speckledwithStars.net>


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

    Some examples:

    http://wiki.wxpython.org/RecipesImagesAndGraphics

    Mike
     
    , Sep 18, 2007
    #4
  5. On 2007-09-18, W. Watson <> wrote:

    > 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

    --
    Grant Edwards grante Yow! As President I have
    at to go vacuum my coin
    visi.com collection!
     
    Grant Edwards, Sep 18, 2007
    #5
  6. W. Watson

    W. Watson Guest

    Re: Tutorial or Example (or Tutorial) of Using Canvas to Producea Plot

    Tk is it. I'm really not interested in the others at this point.

    Grant Edwards wrote:
    > On 2007-09-18, W. Watson <> wrote:
    >
    >> 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
    >


    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
     
    W. Watson, Sep 18, 2007
    #6
  7. Richard Townsend, Sep 18, 2007
    #7
  8. W. Watson

    W. Watson Guest

    Re: Tutorial or Example (or Tutorial) of Using Canvas to Producea Plot

    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.


    Richard Townsend wrote:
    > On Tue, 18 Sep 2007 13:18:36 -0700, "W. Watson"
    > <> wrote:
    >
    >> Tk is it. I'm really not interested in the others at this point.
    >>

    >
    > 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
    >
    > See http://www.manning.com/grayson/ for more info about the book.
    >


    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
     
    W. Watson, Sep 19, 2007
    #8
  9. W. Watson

    W. Watson Guest

    Re: Tutorial or Example (or Tutorial) of Using Canvas to Producea Plot

    Ah, I missed your link to Chap 11. That looks very helpful.

    W. Watson wrote:
    > 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.
    >
    >
    > Richard Townsend wrote:
    >> On Tue, 18 Sep 2007 13:18:36 -0700, "W. Watson"
    >> <> wrote:
    >>
    >>> Tk is it. I'm really not interested in the others at this point.
    >>>

    >>
    >> 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
    >>
    >> See http://www.manning.com/grayson/ for more info about the book.
    >>

    >


    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
     
    W. Watson, Sep 19, 2007
    #9
  10. W. Watson

    exhuma.twn Guest

    On Sep 18, 11:58 pm, Richard Townsend <> wrote:
    > On Tue, 18 Sep 2007 13:18:36 -0700, "W. Watson"
    >
    > <> wrote:
    > >Tk is it. I'm really not interested in the others at this point.

    >
    > 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.
     
    exhuma.twn, Sep 19, 2007
    #10
  11. W. Watson

    W. Watson Guest

    Re: Tutorial or Example (or Tutorial) of Using Canvas to Producea Plot

    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.

    exhuma.twn wrote:
    > On Sep 18, 11:58 pm, Richard Townsend <> wrote:
    >> On Tue, 18 Sep 2007 13:18:36 -0700, "W. Watson"
    >>
    >> <> wrote:
    >>> Tk is it. I'm really not interested in the others at this point.

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


    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
     
    W. Watson, Sep 19, 2007
    #11
  12. W. Watson

    W. Watson Guest

    Re: Tutorial or Example (or Tutorial) of Using Canvas to Producea Plot

    Here seems to be another good source. <http://effbot.org/tkinterbook/canvas.htm>

    W. Watson wrote:
    > Ah, I missed your link to Chap 11. That looks very helpful.
    >
    > W. Watson wrote:
    >> 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.
    >>
    >>
    >> Richard Townsend wrote:
    >>> On Tue, 18 Sep 2007 13:18:36 -0700, "W. Watson"
    >>> <> wrote:
    >>>
    >>>> Tk is it. I'm really not interested in the others at this point.
    >>>>
    >>>
    >>> 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
    >>>
    >>> See http://www.manning.com/grayson/ for more info about the book.
    >>>

    >>

    >


    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
     
    W. Watson, Sep 19, 2007
    #12
  13. Re: Tutorial or Example (or Tutorial) of Using Canvas to Producea Plot

    "W. Watson" <> wrote:


    > 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
     
    Hendrik van Rooyen, Sep 20, 2007
    #13
  14. W. Watson

    W. Watson Guest

    Re: Tutorial or Example (or Tutorial) of Using Canvas to ProduceaPlot

    That's odd; however, it's likely close enough.

    Hendrik van Rooyen wrote:
    > "W. Watson" <> wrote:
    >
    >
    >> 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
    >


    --
    Wayne Watson (Nevada City, CA)

    Web Page: <speckledwithStars.net>
     
    W. Watson, Sep 20, 2007
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Askari
    Replies:
    2
    Views:
    739
    Askari
    Aug 30, 2004
  2. PhilC
    Replies:
    2
    Views:
    928
    PhilC
    Oct 25, 2004
  3. Dr. Colombes
    Replies:
    1
    Views:
    1,078
    John Hunter
    Feb 10, 2005
  4. Replies:
    5
    Views:
    496
    Luc The Perverse
    Oct 27, 2006
  5. Replies:
    10
    Views:
    299
    Rick Johnson
    Mar 15, 2013
Loading...

Share This Page