Gnuplot_demo.pm (PDL-2.074) | : | Gnuplot_demo.pm (PDL-2.075) | ||
---|---|---|---|---|

skipping to change at line 136 | skipping to change at line 136 | |||

# A two-line plot with legend. | # A two-line plot with legend. | |||

# The legend for each line separates the groups of PDL data. | # The legend for each line separates the groups of PDL data. | |||

$w->options(title=>"Two lines (with legend)", key=>'left'); | $w->options(title=>"Two lines (with legend)", key=>'left'); | |||

$w->lines( legend=>"sin",$x,$y, legend=>"cos",$x,$y2 ); | $w->lines( legend=>"sin",$x,$y, legend=>"cos",$x,$y2 ); | |||

# | # | |||

|; | |; | |||

act q| | act q| | |||

# You can also generate multiline plots with threading. | # You can also generate multiline plots with broadcasting. | |||

# Here, $x is a 1000-element 1-D PDL, and $yy is a 1000x2 2-D PDL. | # Here, $x is a 1000-element 1-D PDL, and $yy is a 1000x2 2-D PDL. | |||

$x = xvals(1000)/1000; | $x = xvals(1000)/1000; | |||

($y,$y2) = ( $x * sin(100 * $x), sqrt($x) * cos(100 * $x) ); | ($y,$y2) = ( $x * sin(100 * $x), sqrt($x) * cos(100 * $x) ); | |||

$yy = pdl( $y, $y2 ); | $yy = pdl( $y, $y2 ); | |||

# all options can be abbreviated to the smallest unique string. | # all options can be abbreviated to the smallest unique string. | |||

# Here, "tit" stands for "title", and "le" for "legend". | # Here, "tit" stands for "title", and "le" for "legend". | |||

$w->lines({tit=>"2-lines threaded"}, le=>["sin", "cos"], $x, $yy); | $w->lines({tit=>"2-lines broadcasted"}, le=>["sin", "cos"], $x, $yy); | |||

|; | |; | |||

act q| | act q| | |||

# line plots are far from the only thing you can do! | # line plots are far from the only thing you can do! | |||

# Here is the same plot, with points and some tweaks to the axis labels. | # Here is the same plot, with points and some tweaks to the axis labels. | |||

$w->options(tit=>"2 sets of points"); | $w->options(tit=>"2 sets of points"); | |||

$l = ["sin", "cos"]; | $l = ["sin", "cos"]; | |||

End of changes. 2 change blocks. | ||||

2 lines changed or deleted | | 2 lines changed or added |