SPUG: X-Y scatter-plotting with annotated datapoints

Jeremy Calvert jeremycalvert2000 at yahoo.com
Fri Aug 16 16:11:10 CDT 2002


A cheap and dirty option:
----
use GD::Graph::lines;

my @data;
for(my $i=0; $i<=245; $i++){
  ${$data[0]}[$i] = undef;
  ${$data[1]}[$i] = undef;
}
${$data[0]}[0] = "0 S";
${$data[1]}[0] = 120;
  
${$data[0]}[20] = "20 S";
${$data[1]}[20] = 118;
  
${$data[0]}[30] = "30 i";
${$data[1]}[30] = 110;
  
...and so on...

$my_graph = new GD::Graph::lines();
$my_graph->plot(\@data);

------

which is to say, by filling in two 245 element arrays
with nulls, then sprinkling in your data in the way
indicated above, then passing them to GD::Graph, and
plotting them as a line graph, it does what you want
it to...It spaces the points on the x-axis correctly
and connects the actual data points (as opposed to
(undef, undef) points) with straight lines.

YASJ

--- SPUG-list-owner <tim at consultix-inc.com> wrote:
> On Thu, Aug 15, 2002 at 02:43:31PM -0700, Jeremy
> Kahn wrote:
> 
> Hi Jeremy,
> 
> Why not just color-code the dots to the phonetic
> labels?  Of course,
> if you have more data points than your printer or
> human vision can
> differentiate, or if they would overlap, then this
> approach might
> not be feasible.
> 
> Having blithely offered that easy solution, I
> suppose your next question
> would be what software will do this for you! 
> Unfortunately, I don't
> have the answer to that, but perhaps this idea will
> help you redirect
> your search in the right quarters (for "scatterplot"
> software, e.g.).
> 
> -Tim
>
*----------------------------------------------------------------------------*
> | Tim Maher, CEO, CONSULTIX  (206) 781-UNIX; (866)
> DOC-PERL; (866) DOC-LINUX |
> |  Ph.D. & JAWCAR ("Just Another White Camel Award
> Recipient")               |
> |  tim at consultix-inc.com  teachmeunix.com 
> teachmeperl.com  teachmelinux.net |
> |       UPCOMING CLASSES:   9/18: Int. Perl   9/23:
> Shell & Utilities        |
>
*----------------------------------------------------------------------------*
> 
> > SPUGsters --
> > 
> > So I've got this complex data-set representing
> phonetic symbols and a
> > couple of pitch and timing values (in milliseconds
> and Hertz) for each
> > symbol. (This is data emitted by a text processing
> engine, coming up with
> > a plausible prosody for text-to-speech synthesis).
> Sample (and entirely
> > bogus) data is at the bottom of this note.
> > 
> > What I'd like to do is an X-Y plot (where time in
> ms is the X axis, and
> > Hz is the Y axis, with each "target" representing
> a point on that plot).
> > Ideally, the dots should be connected along the
> timeline (in their X
> > ordering).
> > 
> > More important than the connectedness, though, is
> that the targets be
> > associated with the phonetic symbols they are
> subordinate to.  These data
> > are pretty much worthless as a series of points if
> I can't synchronize
> > those points to the phonetic symbols.  I can think
> of two nice ways to
> > demonstrate the synchronization:
> > 
> >   * attach the phone symbol to each point
> >   * plot the phone symbols as regions along the X
> axis
> > 
> > But I've gotten stuck looking for a tool that can
> build me this graph.  I
> > experimented with Excel's graphing abilities -- no
> dice, as far as I could
> > tell, since I could get the X-Y plot, but no way
> to attach the phone
> > symbols, or I could get the phone symbols, but
> then they were
> > evenly-spaced along the X (time!) axis, despite
> their widely varying time
> > signatures.
> > 
> > I once solved a problem like this using SAS, but I
> don't have it now and I
> > don't have the budget.
> > 
> > So, I thought, I'll turn to Perl, since everything
> is easier in Perl.
> > (It is, isn't it?) I found Martin Verbruggen's
> GD::Graph, which is very
> > spiffy, but doesn't have a way to do this all
> neatly packaged. Before I
> > plunge in to write an extension to GD::Graph (or
> -- please, no -- write it
> > directly in GD!), does anybody have any ideas or
> advice?  Has anybody
> > solved a problem like this before using Perl?
> > 
> > --Jeremy
> > 
> > 
> > Data follows:
> > Note the format below is not what I'm using; I've
> got it in XML, so it's
> > completely parsed. I am *not* interested in help
> parsing the data, just
> > giving some sense of the kind of data I have.
> > 
> > Input text: "she had"
> > 
> > __DATA__
> > 
> > ms    Hz    phonetic-symbol
> > ---------------------------
> > 0     120   S
> > 20    118   (also S)
> > 30    110   i
> > 70    125   (also i)
> > 90    120   h
> > 120   110   (also h)
> > 170   108   A
> > 200   105   (also A)
> > 210   100   d
> > 245    95   (also d)
> 
>  - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - - - -
>      POST TO: spug-list at pm.org       PROBLEMS:
> owner-spug-list at pm.org
>       Subscriptions; Email to majordomo at pm.org: 
> ACTION  LIST  EMAIL
>   Replace ACTION by subscribe or unsubscribe, EMAIL
> by your Email-address
>  For daily traffic, use spug-list for LIST ;  for
> weekly, spug-list-digest
>      Seattle Perl Users Group (SPUG) Home Page:
> http://seattleperl.org
> 


__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list