Hello!

I have to plot several diagramms and want to do it with chart::gnuplot.

It needs the x and y as arrayref with
xdata => \@xarray, ydata => \@yarray,
I want to plot the diagramms with a loop.
Where the data is coming from is different for the loop elements, so that I have to put it before into a structure, over it then I can loop.
Not every index is filled. First I try to differ between and choose therefore i and ii, but then I dicide to use only the index i and skip the unfilled indexe during plotting.
This is the part of my code:
# die Plotfelder/-hashe belegen und hash istart $ii = -1; for ($i = 0; $i <= $#yfeld; $i++) { # next if ($yfeld[$i] == 0); $ii = $ii + 1; print "$i $ii "; push(@ploty,$yfeld[$i]); push @{$istart{$ii}}, $istart[$i]; push @{$ianz{$ii}}, $ianz[$i]; if ($xfeld[$i] eq 'x') { push @{$plotx{$ii}}, @xfix; print "x\n"; } elsif ($xfeld[$i] eq 'y') { push @{$plotx{$ii}}, @yfix; print "y\n"; } else { push @{$plotx{$ii}}, $fnfeld[$xfeld[$i]]->{'fn'}; print "$xfeld[$i]\n"; } } print "\n"; print "2 $plotx{2}[3]\n"; print "3 $plotx{3}[3]\n"; print "5 $plotx{5}[3]\n"; # ? print "6 $plotx{6}[3]\n"; print "7 $plotx{7}[3]\n"; # ? print "8 $plotx{8}[3]\n"; # ? print "9 $plotx{9}[3]\n";
The prints in the loop are for checking. It seems all correct.
0 0 0 1 1 0 2 2 y 3 3 y 4 4 0 5 5 5 6 6 x 7 7 5 8 8 5 9 9 y
I ommit the index 0, 1, 4, because it is empty (0 in the first print-block).
But the print-check at the end of my code snippet gives this:
2 3.640000E-04 3 3.640000E-04 Use of uninitialized value in concatenation (.) or string at test.pl l +ine 590. 5 6 3.640250E-04 Use of uninitialized value in concatenation (.) or string at test.pl l +ine 592. 7 Use of uninitialized value in concatenation (.) or string at test.pl l +ine 593. 8 9 3.640000E-04
So it means, that something goes wrong, where I want to assign the fnfeld to my plotx.
I read this "References quick reference" and my brain has meanwhile several knots to thinking about this. But I have no idea, what is wrong with the syntax.
I think, it is the reference, because I use it successfull for plotting:
ydata => $fnfeld[$ploty[$ii]]->{'fn'},
But how can I assing the values from the array of hashes, which contains an array?

Regards, buchi


In reply to question to a complex structure of hash/array by buchi2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.