Help with plotting

D

Deepu

Hi All,

I am trying to generate a bar chart after creating a table out of the
information in a file.

I have file which contains so many other details and have a line in the
file which start with:

#RESULT: 30 => YES: 10 NO: 10 UNKNOWN: 10

I have several files with each file have a line with RESULT.

The code to store the number of YES, NO and UNKNOWN:

#!/usr/bin/perl

@dirList= qw(FILE1 FILE2 FILE3 FILE4 FILE5);

foreach $dir (@dirList) {
open (PH, "$dir") || die "Can not open:$dir";

while (<PH>) {
if (/#RESULT: (\d+) => YES: (\d+) NO: (\d+) UNKNOWN: (\d+)/) {
push (@yesArray, $2);
push (@noArray, $3);
push (@unknownArray, $4);
}
}

close (PH);
}

Now i am trying to display it in a table format:

YES NO UNKNOWN
FILE1 10 8 14
FILE2 6 7 20
FILE3 18 10 10
FILE4 20 12 10
FILE5 10 10 10

After printing this out how to create abar chart out of it in perl with
X axis showing FILE number and has 3 bars for each file.

Thanks for the help.
 
M

Mumia W.

Hi All,

I am trying to generate a bar chart after creating a table out of the
information in a file.

I have file which contains so many other details and have a line in the
file which start with:

#RESULT: 30 => YES: 10 NO: 10 UNKNOWN: 10

I have several files with each file have a line with RESULT.

The code to store the number of YES, NO and UNKNOWN:

#!/usr/bin/perl

@dirList= qw(FILE1 FILE2 FILE3 FILE4 FILE5);

foreach $dir (@dirList) {
open (PH, "$dir") || die "Can not open:$dir";

while (<PH>) {
if (/#RESULT: (\d+) => YES: (\d+) NO: (\d+) UNKNOWN: (\d+)/) {
push (@yesArray, $2);
push (@noArray, $3);
push (@unknownArray, $4);
}
}

close (PH);
}

Now i am trying to display it in a table format:

YES NO UNKNOWN
FILE1 10 8 14
FILE2 6 7 20
FILE3 18 10 10
FILE4 20 12 10
FILE5 10 10 10

After printing this out how to create abar chart out of it in perl with
X axis showing FILE number and has 3 bars for each file.

Thanks for the help.

I'm in a really good mood right now:

use strict;
use warnings;
use PDL;
use PDL::Graphics::pLplot;
my @yesArray = qw(10 6 18 20 10);
my @noArray = qw(8 7 10 12 10);
my @unknownArray = qw(14 20 10 10 10);

my $fmt = "%-10s %5s %5s %5s\n";
printf ($fmt, '', qw(YES NO UNKNOWN));
printf $fmt, 'FILE'.($_+1), $yesArray[$_],
$noArray[$_], $unknownArray[$_] for (0..$#yesArray);

my $pl = PDL::Graphics::pLplot->new(DEV => 'pbm',
FILE => 'make_yn_table.pbm');
$pl->setparm(PLOTTYPE => 'LINEPOINTS', LINEWIDTH => 4);
my $x = sequence(scalar @yesArray)+1;
$pl->xyplot($x, pdl [ @yesArray ] );
$pl->xyplot($x, pdl [ @noArray ], COLOR => 'RED');
$pl->xyplot($x, pdl [ @unknownArray ], COLOR => 'BLUE');
print $x;
$pl->close;


For some reason, I never get color in the output PBM file. The docs say
that the module supports PPMs. So why no color?

Also, the line-width that I set is ignored. Why?
 
J

John W. Krahn

Deepu said:
I am trying to generate a bar chart after creating a table out of the
information in a file.

I have file which contains so many other details and have a line in the
file which start with:

#RESULT: 30 => YES: 10 NO: 10 UNKNOWN: 10

I have several files with each file have a line with RESULT.

The code to store the number of YES, NO and UNKNOWN:

#!/usr/bin/perl

@dirList= qw(FILE1 FILE2 FILE3 FILE4 FILE5);

foreach $dir (@dirList) {
open (PH, "$dir") || die "Can not open:$dir";

while (<PH>) {
if (/#RESULT: (\d+) => YES: (\d+) NO: (\d+) UNKNOWN: (\d+)/) {
push (@yesArray, $2);
push (@noArray, $3);
push (@unknownArray, $4);
}
}

close (PH);
}

Now i am trying to display it in a table format:

YES NO UNKNOWN
FILE1 10 8 14
FILE2 6 7 20
FILE3 18 10 10
FILE4 20 12 10
FILE5 10 10 10


format STDOUT_TOP =
YES NO UNKNOWN
..

format STDOUT =
@<<<<<<<<< @>>>>>>>> @>>>>>>>> @>>>>>>>>
$ARGV, $1, $2, $3
..

@ARGV = qw( FILE1 FILE2 FILE3 FILE4 FILE5 );

while ( <> ) {
/#RESULT:\s+\d+\s+=>\s+YES:\s+(\d+)\s+NO:\s+(\d+)\s+UNKNOWN:\s+(\d+)/
&& write
&& close ARGV
}




John
 
D

Deepu

Thanks a lot for the help. I tried the below code and am getting an
error like:

Can't locate PDL/Graphics/PLplot.pm in @INC

Can somebody please let me know what changes need to be done.

Thanks

use strict;
use warnings;
use PDL;
use PDL::Graphics::pLplot;
my @yesArray = qw(10 6 18 20 10);
my @noArray = qw(8 7 10 12 10);
my @unknownArray = qw(14 20 10 10 10);


my $fmt = "%-10s %5s %5s %5s\n";
printf ($fmt, '', qw(YES NO UNKNOWN));
printf $fmt, 'FILE'.($_+1), $yesArray[$_],
$noArray[$_], $unknownArray[$_] for (0..$#yesArray);


my $pl = PDL::Graphics::pLplot->new(DEV => 'pbm',
FILE => 'make_yn_table.pbm');
$pl->setparm(PLOTTYPE => 'LINEPOINTS', LINEWIDTH => 4);
my $x = sequence(scalar @yesArray)+1;
$pl->xyplot($x, pdl [ @yesArray ] );
$pl->xyplot($x, pdl [ @noArray ], COLOR => 'RED');
$pl->xyplot($x, pdl [ @unknownArray ], COLOR => 'BLUE');
print $x;
$pl->close;
 
D

David Squire

Deepu said:
Thanks a lot for the help. I tried the below code and am getting an
error like:

Can't locate PDL/Graphics/PLplot.pm in @INC

Can somebody please let me know what changes need to be done.

Ermmm.... install the module?

If you have already installed it, then it must be in a non-standard
place w.r.t. your Perl installation, and you will have to tell Perl
where to look via a "use lib '/path/to/directory/where/module/is';" line
at the top of the script.


DS
 
E

Eric Schwartz

Michele Dondi said:
OTOH they're sometimes too picky for my tastes. While developing
something on a debian box I had been needing a module which relied on
a certain package. I had a hard time trying to install and put the
module to work until I realized it wanted a -devel part of the package
too.

But this is true of Redhat and Suse, or at least their enterprise
distros, with which I have some passing familiarity. RHEL4 update 4
has 255 -devel packages, each with its own non-devel. Offhand, I
haven't checked how many packages don't have -devel equivalents, but
it's clearly not uncommon there either.

-=Eric
 
P

Peter J. Holzer

Yup.

To cut it short, I was trying to install RRDTool::OO. This is not
surprisingly an OO interface to RRDtool. The latter is a single
software package which has its own perl interface, RRDs, also used by
R::O. In the end it all boiled down to the fact that Debian *splitted*
RRDtool into rrdtool and librrds-perl which provides RRDs, whereas I'd
like to underline that RRDs is part of the "core" RRDtool distro, and
not a separate add-on. So again, just a little bit too picky IMHO...

This is common for many Linux distributions. It is often the case that
some software consists of a library and some command-line tools. In this
case it is often split into three packages: A library package, which
contains the libraries and assorted files needed at run-time, a package
which contains the command line tools, and a devel-package, which
contains all the stuff which isn't needed at run-time, but for
developing other software which uses the library. So if you need only
the library (e.g., because it is used by some other software), you need
to install only the library package, but not the tools and development
packages. Saves some disk-space and makes the system easier to maintain
(software which isn't installed can't break).

hp

PS: AFAICS, perl is split into 9 packages on Debian.
 

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

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top