[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

CanvasPlot, createPlotAxis and createLinePlot.

Patrick Lynch

9/27/2006 9:48:00 PM

Good afternoon,

I'm trying to get a line plot (x-y coordinates with a line) up and
running on a Windows XP/Pro box.
I'm using references:
1. The "Pick Axe" book
2. "Mastering Perl/Tk"

The three classes or methods that will do everything I want, as shown in
ref 2, are:
1. CanvasPlot
2. createLinePlot
3. createPlotAxis

What is the 'require' that is required to make these Class/Methods known
to a Ruby program...

Thanks,
Pat


--
Posted via http://www.ruby-....

10 Answers

Paul Lutus

9/27/2006 10:17:00 PM

0

Patrick Lynch wrote:

/ ...

> The three classes or methods that will do everything I want, as shown in
> ref 2, are:
> 1. CanvasPlot
> 2. createLinePlot
> 3. createPlotAxis
>
> What is the 'require' that is required to make these Class/Methods known
> to a Ruby program...

Most likely:

require 'tk'

--
Paul Lutus
http://www.ara...

Patrick Lynch

9/28/2006 12:23:00 AM

0

Paul Lutus wrote:
> Patrick Lynch wrote:
>
> / ...
>
>> The three classes or methods that will do everything I want, as shown in
>> ref 2, are:
>> 1. CanvasPlot
>> 2. createLinePlot
>> 3. createPlotAxis
>>
>> What is the 'require' that is required to make these Class/Methods known
>> to a Ruby program...
>
> Most likely:
>
> require 'tk'

I tried 'tk'...but it doesn't work...bummer...

--
Posted via http://www.ruby-....

Morton Goldberg

9/28/2006 1:56:00 AM

0

On Sep 27, 2006, at 5:47 PM, Patrick Lynch wrote:

> I'm trying to get a line plot (x-y coordinates with a line) up and
> running on a Windows XP/Pro box.
> I'm using references:
> 1. The "Pick Axe" book
> 2. "Mastering Perl/Tk"
>
> The three classes or methods that will do everything I want, as
> shown in
> ref 2, are:
> 1. CanvasPlot
> 2. createLinePlot
> 3. createPlotAxis
>
> What is the 'require' that is required to make these Class/Methods
> known
> to a Ruby program...

AFIK, TK::CanvasPlot is Perl only and is not available in the Ruby/Tk
libraries.

Regards, Morton

Patrick Lynch

9/28/2006 10:34:00 AM

0

Morton Goldberg wrote:
> On Sep 27, 2006, at 5:47 PM, Patrick Lynch wrote:
>
>> 2. createLinePlot
>> 3. createPlotAxis
>>
>> What is the 'require' that is required to make these Class/Methods
>> known
>> to a Ruby program...
>
> AFIK, TK::CanvasPlot is Perl only and is not available in the Ruby/Tk
> libraries.
>
> Regards, Morton

Thanks Morton. Too bad, it does exactly what I need to do...what I'm
trying to do is to create a Line Plot with labeled x & y coordinates and
with tick marks on the coordinates...

I haven't seen anything like this in the 'Pick Axe' book. I'll check the
Tk classes...if you know of anything that I can use, please pass it on
to me...

Good day,
Pat

--
Posted via http://www.ruby-....

Morton Goldberg

9/28/2006 3:28:00 PM

0

On Sep 28, 2006, at 6:34 AM, Patrick Lynch wrote:

> I haven't seen anything like this in the 'Pick Axe' book. I'll
> check the
> Tk classes...if you know of anything that I can use, please pass it on
> to me...

I'm afraid I can't help you. I don't do that kind of programming with
Ruby/Tk. When I need a line plot or any other kind of data plot, I
use Mathematica.

Discussions previously appearing on this ML indicate you can drive
GNUPlot from Ruby. You might look into that. Here a URL that could
get started:

http://rgnuplot.source...

Regards, Morton

Hidetoshi NAGAI

9/28/2006 7:05:00 PM

0

Patrick Lynch

9/28/2006 7:51:00 PM

0

Hidetoshi NAGAI wrote:
> From: Patrick Lynch <lynchnco@patmedia.net>
> Subject: Re: CanvasPlot, createPlotAxis and createLinePlot.
> Date: Thu, 28 Sep 2006 19:34:06 +0900
> Message-ID: <91de7c204d366491276290198798b3dd@ruby-forum.com>
>> >> 2. createLinePlot
>> >> 3. createPlotAxis
>
> Those seem Perl's simple subroutines.
> It will be not difficult that you write such methods on Ruby/Tk.
>
> If you want to create a line item "line" on the canvas "c",
> ----------------------------------------------------------------
> line = TkcLine.new(c, <...coords...>, <...options...>)
> ----------------------------------------------------------------
> e.g. line = TkcLine.new(c, 0, 0, 10, 5, 20, 30, :fill=>'red')
> or
> line = TkcLine.new(c, [0, 0, 10, 5, 20, 30], :fill=>'red')
> or
> line = TkcLine.new(c, [0, 0], [10, 5], [20, 30], :fill=>'red')
> or
> line = TkcLine.new(c, [[0, 0], [10, 5], [20, 30]], :fill=>'red')
>
> If you want an arc item, please use TkcArc class.

Hi,

I've done that...can you tell me how to add tick marks and coordinate
values and possibly even coordinate labels?

FYI

0----10----20----30----40---...
Label: this is the x-axis...

a similar thing for the y-axis...

THX



--
Posted via http://www.ruby-....

Hidetoshi NAGAI

9/29/2006 2:36:00 AM

0

Patrick Lynch

9/29/2006 10:34:00 AM

0

Hidetoshi NAGAI wrote:
>
> It seems that the package is constructed with standard canvas items
> only.
> Why don't you translate it to Ruby/Tk? ;-)
> Anyway, translation is not so difficult, if you can read the Perl
> source.
> For example,
> ----<Perl/Tk>--------------------------------------------------
> if ($y_axis) {
> $self->createText(
> $x1-$tl, $y2-$x, -text => $l,
> %args, -fill => $tcolor,
> -font => $lfont, -anchor => $an,
> );
> } else {
> $self->createText(
> $x+$x1, $y1+$tl, -text => $l,
> %args, -fill => $tcolor,
> -font => $tfont, -anchor => $an,
> );
> }
> ---------------------------------------------------------------
> ----<Ruby/Tk>--------------------------------------------------
> if (y_axis) {
> TkcText.new(self, x1-tl, y2-x,
> args.merge(:text=>l, :fill=>tcolor,
> :font=>lfont, :anchor=>an)
> )
> } else {
> TkcText.new(self, x+x1, y1+tl,
> args.merge(:text=>l, :fill=>tcolor,
> :font=>tfont, :anchor=>an)
> )
> }
> ---------------------------------------------------------------
>
> However, if you want to create beautiful graphs,
> I recommend you to use BLT ( or Tcllib(Tklib) ) extension.
> Current Ruby/Tk has a binding for BLT ( and Tcllib(Tklib) ).

Hidetoshi,
Thank you, I shall try both techniques...
I'm developing a Quality Assurance Metrics package...so I will need do
do some beautiful graphs...
When its done, I will dedicate the graphics portion to you.
Ciao,
Pat

--
Posted via http://www.ruby-....

Patrick Lynch

10/16/2006 9:30:00 PM

0

Patrick Lynch wrote:
> Hidetoshi NAGAI wrote:
>>
>> It seems that the package is constructed with standard canvas items
>> only.
>> Why don't you translate it to Ruby/Tk? ;-)
>> Anyway, translation is not so difficult, if you can read the Perl
>> source.
>> For example,
>> ----<Perl/Tk>--------------------------------------------------
>> if ($y_axis) {
>> $self->createText(
>> $x1-$tl, $y2-$x, -text => $l,
>> %args, -fill => $tcolor,
>> -font => $lfont, -anchor => $an,
>> );
>> } else {
>> $self->createText(
>> $x+$x1, $y1+$tl, -text => $l,
>> %args, -fill => $tcolor,
>> -font => $tfont, -anchor => $an,
>> );
>> }
>> ---------------------------------------------------------------
>> ----<Ruby/Tk>--------------------------------------------------
>> if (y_axis) {
>> TkcText.new(self, x1-tl, y2-x,
>> args.merge(:text=>l, :fill=>tcolor,
>> :font=>lfont, :anchor=>an)
>> )
>> } else {
>> TkcText.new(self, x+x1, y1+tl,
>> args.merge(:text=>l, :fill=>tcolor,
>> :font=>tfont, :anchor=>an)
>> )
>> }
>> ---------------------------------------------------------------
>>
>> However, if you want to create beautiful graphs,
>> I recommend you to use BLT ( or Tcllib(Tklib) ) extension.
>> Current Ruby/Tk has a binding for BLT ( and Tcllib(Tklib) ).
>
> Hidetoshi,
> Thank you, I shall try both techniques...
> I'm developing a Quality Assurance Metrics package...so I will need do
> do some beautiful graphs...
> When its done, I will dedicate the graphics portion to you.
> Ciao,
> Pat

I finally got the Perl version of Tk::CanvasPlot up an running -- see
the book "Mastering Perl/Tk" by Steve Lidie and Nancy Walsh...I now need
to convert this Perl Code to Ruby....

BTW, I tried to make 'BLT' known to one of my Ruby scripts but am unable
to do so...Will you please tell me how to do this....

Finally, if anyone is going to use Tk::CanvasPlot in the book mentioned
above, give me an email...there is one method that is not included in
the text...

Good day


--
Posted via http://www.ruby-....