saunderson has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I want to fall back on features provided by 'tcllib'. Particularly i want to use the plotting package 'Plotchart'. So far i was able to depict a coordinate system in a canvas object with the line

my $plot = Tkx::Plotchart__createXYPlot($canvas, [-2, 1, 1], [-2, 2, 2]);

after i include the package with

Tkx::package_require("Plotchart");

But, of course, the function Tkx::Plotchart__createXYPlot doesn't return an object so i'm failing to manipulate the plot further. For example with the 'plot' function that applies on a $xyplot

Certainly 'Tkx.pm' is able to handle this case, but i didn't have luck so far.

I hope that one of you Monks can show me the right way how to access the plot at later times.

Thank you very much for your effort and with best regards

s.

Replies are listed 'Best First'.
Re: Tkx.pm: invoke features of 'tcllib'
by Anonymous Monk on Feb 19, 2012 at 23:24 UTC

    But, of course, the function Tkx::Plotchart__createXYPlot doesn't return an object so i'm failing to manipulate the plot further.

    Of course it returns an object

      Ok, it returns a string, a path, but every such tk path is an object if given to  Tkx::widget->new()

      #!/usr/bin/perl -- use strict; use warnings; use Tkx; local $Tkx::TRACE=64; Tkx::package_require(q/Plotchart/); my $mw = Tkx::widget->new("."); my $canvas = $mw->new_tk__canvas( qw/-background white /); $canvas->g_pack(qw/ -expand 1 -fill both /); my $s = Tkx::Plotchart__createXYPlot($canvas, [qw{0.0 100.0 10.0}], [ +qw{0.0 100.0 20.0}] ); $s = Tkx::widget->new( $s ); my @xy = qw{0.0 32.0 10.0 50.0 25.0 60.0 78.0 11.0 }; for( my $ix = 0; $ix < @xy; $ix+=2 ){ my $x = $xy[$ix]; my $y = $xy[$ix+1]; $s->plot("series1", $x, $y); } $s->title("Data series"); $mw->g_wm_withdraw(); $mw->g_wm_deiconify(); Tkx::MainLoop(); __END__ #~ http://tcllib.sourceforge.net/doc/plotchart.html #~ package require Plotchart #~ #~ canvas .c -background white -width 400 -height 200 #~ pack .c -fill both #~ #~ # #~ # Create the plot with its x- and y-axes #~ # #~ set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 + 20.0}] #~ #~ foreach {x y} {0.0 32.0 10.0 50.0 25.0 60.0 78.0 11.0 } { #~ $s plot series1 $x $y #~ } #~ #~ $s title "Data series __END__ Tkx-1-0.0s---5: package require Plotchart Tkx-2-0.1s---7: winfo children . Tkx-3-0.1s---7: tk::canvas .c -background white Tkx-4-0.1s---8: pack .c -expand 1 -fill both Tkx-5-0.1s---9: Plotchart::createXYPlot .c [list 0.0 100.0 10.0] [list + 0.0 100.0 20.0] Tkx-6-0.1s---16: xyplot_.c plot series1 0.0 32.0 Tkx-7-0.1s---16: xyplot_.c plot series1 10.0 50.0 Tkx-8-0.1s---16: xyplot_.c plot series1 25.0 60.0 Tkx-9-0.1s---16: xyplot_.c plot series1 78.0 11.0 Tkx-10-0.1s---18: xyplot_.c title {Data series} Tkx-11-0.1s---20: wm withdraw . Tkx-12-0.1s---21: wm deiconify .
        Ok, it returns a string, a path, but every such tk path is an object if given to Tkx::widget->new()
        This is most likely the part of the Tkx documentation i have read over.

        Thank you very much for this statement and moreover for the instructive example. You helped me a lot!

        with best regards, s.