CanvasPlot, createPlotAxis and createLinePlot.

P

Patrick Lynch

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
 
M

Morton Goldberg

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
 
P

Patrick Lynch

Morton said:
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
 
M

Morton Goldberg

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.sourceforge.net/

Regards, Morton
 
H

Hidetoshi NAGAI

From: Patrick Lynch <[email protected]>
Subject: Re: CanvasPlot, createPlotAxis and createLinePlot.
Date: Thu, 28 Sep 2006 19:34:06 +0900

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

Patrick Lynch

Hidetoshi said:
From: Patrick Lynch <[email protected]>
Subject: Re: CanvasPlot, createPlotAxis and createLinePlot.
Date: Thu, 28 Sep 2006 19:34:06 +0900

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
 
H

Hidetoshi NAGAI

From: Patrick Lynch <[email protected]>
Subject: Re: CanvasPlot, createPlotAxis and createLinePlot.
Date: Fri, 29 Sep 2006 04:51:28 +0900
Message-ID: said:
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...

Do you want to use this from Ruby?
vvvv
<http://perl.codefetch.com/example/da/mptk-code14/Tk/CanvasPlot.pm>

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)
)
}
 
P

Patrick Lynch

Hidetoshi said:
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
 
P

Patrick Lynch

Patrick said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,158
Latest member
Vinay_Kumar Nevatia
Top