Yeah, basically you just want to set up a Canvas and plot your points by making "tiny circles". Here is an example using Tk::Axis, which makes a nice cartesian axis for you. It is based on Canvas. If you need help on how to plot your "tiny circles", let me know. Just read "perldoc Tk::Canvas" and search for "createOval".

I will mention one thing, if you have too many datapoints, you may find it slow to display. You probably can get around it by updating your Canvas after every 100 points or so, so you will see the graph being drawn.

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Axis; # from Tk-Contrib-0.07 my $mw = MainWindow->new(); $mw->geometry("600x600+10+10"); #the axis widget is a canvas #the origin is in the upper left corner, #so the (0,0) point corresponds to (25,575) #in this example (600 - margin) my $axis = $mw->Axis( -background => 'white', -height => 600, -width => 600, -margin => 25, -tick => 10, #-tickfont => $tickfont, #-tst => $tst, #-width => $width, -xmin => 0, -xmax => 100, -ymin => 0, -ymax => 100, )->pack(); $axis->Tk::bind("<Button-1>", [ \&print_xy, Ev('x'), Ev('y') ]); MainLoop; sub print_xy { print "@_\n"; my ($canv, $x, $y) = @_; print "(x,y) = ", $canv->canvasx($x), ", ", $canv->canvasy($y), "\n" +; }

I'm not really a human, but I play one on earth. flash japh

In reply to Re: Graphs with tk by zentara
in thread Graphs with tk by Lhamo_rin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.