diff --git a/Changes b/Changes index fa39fc2..06ae3ad 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,10 @@ -feedgnuplot (1.42) unstable; urgency=medium +feedgnuplot (1.43) + + * Added --image + + -- Dima Kogan Mon, 19 Jun 2017 13:12:38 -0700 + +feedgnuplot (1.42) * Data can now come from STDIN or files on the cmdline. This fixes a regression. Self-plotting data files work again diff --git a/bin/feedgnuplot b/bin/feedgnuplot index 8142905..f976180 100755 --- a/bin/feedgnuplot +++ b/bin/feedgnuplot @@ -15,7 +15,7 @@ use Text::ParseWords; # for shellwords use Pod::Usage; use Time::Piece; -my $VERSION = 1.42; +my $VERSION = 1.43; my %options; interpretCommandline(); @@ -109,6 +109,7 @@ sub interpretCommandline 'style=s{2}', 'curvestyle=s{2}', 'curvestyleall=s', 'styleall=s', 'with=s', 'extracmds=s@', 'set=s@', 'unset=s@', 'square!', 'square_xy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!', 'timefmt=s', 'equation=s@', + 'image=s', 'histogram=s@', 'binwidth=f', 'histstyle=s', 'terminal=s', 'rangesize=s{2}', 'rangesizeall=i', 'extraValuesPerPoint=i', @@ -419,6 +420,27 @@ sub interpretCommandline } } } + + # deal with --image. I just fill in --equation, and reverse the y extents if + # none are explicitly given + if( defined $options{image} ) + { + # images generally have the origin at the top-left instead of the + # bottom-left, so given nothing else, I flip the y axis + if( !defined $options{ymin} && !defined $options{ymax} && + ! any { /^ *yrange\b/ } @{$options{set}} ) + { + push @{$options{set}}, "yrange [:] reverse"; + } + + if ( ! -r $options{image} ) + { + die "Couldn't read image '$options{image}'"; + } + + push @{$options{equation}}, qq{"$options{image}" binary filetype=auto flipy with rgbimage}; + delete $options{image}; + } } sub getGnuplotVersion @@ -1729,6 +1751,17 @@ times. =item +C<--image filename> + +Overlays the data on top of a raster image given in C. This is passed +through to gnuplot via C<--equation>, and is not interpreted by C +other than checking for existence. Usually images have their origin at the +top-left corner, while plots have it in the bottom-left corner instead. Thus if +the y-axis extents are not specified (C<--ymin>, C<--ymax>, C<--set 'yrange +...'>) this option will also flip around the y axis to make the image appear +properly. Since this option is just a passthrough to gnuplot, finer control can +be achieved by passing in C<--equation> and C<--set yrange ...> directly. + C<--equation xxx> Gnuplot can plot both data and symbolic equations. C generally @@ -1993,11 +2026,21 @@ in a Thinkpad. =head2 Plotting points on top of an existing image -This can be done by using C<--equation> to pass arbitrary plot input to gnuplot: +This can be done with C<--image>: + + $ < features_xy.data + feedgnuplot --points --domain --image "image.png" + +or with C<--equation>: $ < features_xy.data feedgnuplot --points --domain - --equation '"image.png" binary filetype=png flipy with rgbimage' + --equation '"image.png" binary filetype=auto flipy with rgbimage' + --set 'yrange [:] reverse' + +The C<--image> invocation is a convenience wrapper for the C<--equation> +version. Finer control is available with C<--equation>. + Here an existing image is given to gnuplot verbatim, and data to plot on top of it is interpreted by feedgnuplot as usual. C is useful here because diff --git a/completions/bash/feedgnuplot b/completions/bash/feedgnuplot index 81460b1..1cb7e3b 100644 --- a/completions/bash/feedgnuplot +++ b/completions/bash/feedgnuplot @@ -21,6 +21,7 @@ complete -W \ --set \ --unset \ --equation \ + --image \ --geometry \ --hardcopy \ --help \ diff --git a/completions/zsh/_feedgnuplot b/completions/zsh/_feedgnuplot index f29c20f..8826e94 100644 --- a/completions/zsh/_feedgnuplot +++ b/completions/zsh/_feedgnuplot @@ -33,6 +33,7 @@ _arguments -S '*--set[Additional 'set' gnuplot commands]:set-option' \ '*--unset[Additional 'unset' gnuplot commands]:unset-option' \ '*--equation[Raw symbolic equation]:equation' \ + '--image[Image file to render beneath the data]:image' \ '--square[Plot data with square aspect ratio]' \ '--square_xy[For 3D plots, set square aspect ratio for ONLY the x,y axes]' \ '--hardcopy[Plot to a file]:filename' \