Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Welcome to the Monastery
 
PerlMonks  

Re^2: GD vs. gnuplot

by SciDude (Friar)
on Aug 10, 2004 at 02:01 UTC ( #381437=note: print w/ replies, xml ) Need Help??


in reply to Re: GD vs. gnuplot
in thread GD vs. gnuplot

May I ask why you did not use Tk?

Recently for amusement I was looking for a simple way to plot geometrical shapes (polygons, regular solids, pyramids) in the form of a bzflag world map using perl. The thought experiment took me far and wide through various incantations of mesa, openGL/Perl, Glut, Perl SDL, and more. In the end I kept trying options and finding errors and horrible bugs eventually coming full circle (pun intended) back to Perl/Tk.

You may find some examples of interest using Tk:

  1. TkGnuPlot
  2. Data visualization using Perl/Tk
  3. Some great examples at The Ultimate (well, not quite) Perl/Tk Page!!!
  4. Graphing examples from The Perl Journal: Perl and the Tk Extension

Some code (corrected from non-working code found in Advanced Perl Programming) always makes a nice point:

#!/usr/bin/perl -w use Tk; $top = MainWindow->new(); $canvas = $top->Canvas(width => 600, height => 490)->pack(); # Draw a set of circles along an archimedean spiral # The centers of these circles move along the spiral # (radius of spiral = constant * theta)
$origin_x = 110; $origin_y = 70; # origin of the spiral $PI = 3.1415926535; $circle_radius = 5; # radius of the first circl +e $path_radius = 0; for ($angle = 0; $angle <= 180; $path_radius += 7, $circle_radius += 3, $angle += 4) { # offset of path coordinates: r.cos() and r.sin() # sin() and cos() like their angles in radians (degrees*/90) $path_x = $origin_x + $path_radius * cos ($angle * $PI / 90); $path_y = $origin_y - $path_radius * sin ($angle * $PI / 90); # path_x and path_y are the coordinates of the center of the new # circle. Canvas::create likes top-left and bottom-right corners $canvas->createOval ( $path_x - $circle_radius, $path_y - $circle_radius, $path_x + $circle_radius, $path_y + $circle_radius, -fill => 'yellow' ); $canvas->createLine ( $origin_x, $origin_y, $path_x, $path_y, -fill => 'slategray'); } MainLoop();

SciDude
The first dog barks... all other dogs bark at the first dog.


Comment on Re^2: GD vs. gnuplot
Select or Download Code
Re^3: GD vs. gnuplot
by johnnywang (Priest) on Aug 10, 2004 at 05:06 UTC
    Thanks, SciDude. I'm not looking for an interactive program for which Tk would be a choice. I'd prefer no user interaction at all. All I want is to generate images (jpg,png) from some simple intuitive descriptions.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://381437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2014-04-21 06:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls