Hi, Roban, Doug
I've compiled PDL for handlig of BAD values, and using the "setbadat"
function does the trick for me. It took me a while to figure out that
xyplot or plline does not handle BAD-values well if they exist in $y
piddle only. BAD values in $x piddle only works fine. I'm not sure if
it's a bug or supposed to be like that.
This code demonstrates how I omit plotting the third element of the $x
and $y piddles, given that PDL is compiled with BAD values support.
$pl = PDL::Graphics::PLplot->new (DEV => "jpeg", FILE => "test1.jpeg");
$x = sequence(10);
$y = $x**2;
$x->setbadat(2);
#$y->setbadat(2);
$pl->xyplot($x, $y);
$pl->close;
On Thu, 2007-05-03 at 11:09 -0400, Roban Hultman Kramer wrote:
> Kare,
>
> This is not the most elegant solution, but here's the code I use to
> "filter" my data before plotting. It's actually written to exclude
> non-finite values, but could be modified to exclude non-positive
> values instead. You might also want to modify/remove the "else" clause
> that returns fake data when nothing meets the criteria.
>
> I actually use it with PGPLOT, but you could just as easily use it
> with PLPLOT like this
>
> plline( graphclean( $x, $y ) );
>
> sub graphclean{
> my $mask = ones($_[0]); # start by including all points
> foreach my $piddle (@_) { # can be used with N-dimensional data (1,2,3...)
> croak "Dims don't match" unless $mask->dim(0) == $piddle->dim(0);
>
> $mask = $mask * $piddle->isfinite(); # only keep points where
> # every coordinate is finite
>
> # make it work with 2-D piddles
> $mask = andover($mask->transpose()) if $mask->dim(1) > 0;
> }
> if (any $mask) {
> return map {$_->(which($mask))} @_;
> }else {
> carp "graphclean found no good data, making something up.";
> return map {pdl [1,1]} @_;
> }
> }
>
> Hope that's useful.
>
> -roban
>
>
> On 10:48, Thu 03 May 07, Kåre Edvardsen wrote:
> > Finally I've decided to use PLplot for plotting since it handles
> > graphics (PS and jpeg) better than PGplot. I find it not very
> > userfrendly, I'm afraid to say, but I guess I'll get used to it...
> >
> > Only one question for now:
> >
> > How do I specify missing values when plotting?
> >
> > Here, I don't want to plot zero or negative elemets of $y
> >
> > plsdev ("jpeg");
> > plsfnam("test.jpeg");
> > plinit ();
> > pladv (0);
> > plvpor (0.15,0.9,0.15,0.9);
> > plwind (0.0,365.0,0.0,15.0);
> > plbox (0,0,0,0,"bcnst","bcnst");
> > plline ($x, $y);
> > plend ();
> >
> > All the best,
> > Kare
> >
> > ###########################################
> > Kare Edvardsen <[EMAIL PROTECTED]>
> > Norwegian Institute for Air Research (NILU)
> > Polarmiljosenteret
> > NO-9296 Tromso http://www.nilu.no
> > Swb. +47 77 75 03 75 Dir. +47 77 75 03 90
> > Fax. +47 77 75 03 76 Mob. +47 90 74 60 69
> > ###########################################
> >
> >
> >
>
> > _______________________________________________
> > Perldl mailing list
> > [email protected]
> > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl