Full support for all 4 2d axes

Before I'd default to x1y1, and I could use x1y2 if --y2. Now I can ask for
--x1y2 and --x2y1 and --x2y2
This commit is contained in:
Dima Kogan 2019-11-13 13:47:56 -08:00
parent b8111af563
commit d73118087a
3 changed files with 70 additions and 29 deletions

View File

@ -91,7 +91,9 @@ sub interpretCommandline
$options{curvestyle} = []; $options{curvestyle} = [];
$options{style} = []; $options{style} = [];
$options{histogram} = []; $options{histogram} = [];
$options{y2} = []; $options{x1y2} = [];
$options{x2y1} = [];
$options{x2y2} = [];
$options{extracmds} = []; $options{extracmds} = [];
$options{set} = []; $options{set} = [];
$options{unset} = []; $options{unset} = [];
@ -105,9 +107,12 @@ sub interpretCommandline
$options{tuplesize} = []; $options{tuplesize} = [];
GetOptions(\%options, 'stream:s', 'domain!', 'dataid!', 'vnlog!', '3d!', 'colormap!', 'lines!', 'points!', GetOptions(\%options, 'stream:s', 'domain!', 'dataid!', 'vnlog!', '3d!', 'colormap!', 'lines!', 'points!',
'circles', 'legend=s{2}', 'autolegend!', 'xlabel=s', 'ylabel=s', 'y2label=s', 'zlabel=s', 'circles', 'legend=s{2}', 'autolegend!', 'xlabel=s', 'x2label=s', 'ylabel=s', 'y2label=s', 'zlabel=s',
'title=s', 'xlen=f', 'ymin=f', 'ymax=f', 'xmin=s', 'xmax=s', 'y2min=f', 'y2max=f', 'title=s', 'xlen=f',
'zmin=f', 'zmax=f', 'y2=s@', 'xmin=s', 'xmax=s', 'x2min=s', 'x2max=s',
'ymin=f', 'ymax=f', 'y2min=f', 'y2max=f',
'zmin=f', 'zmax=f',
'x2=s@', 'y2=s@', 'x1y2=s@', 'x2y1=s@', 'x2y2=s@',
'style=s{2}', 'curvestyle=s{2}', 'curvestyleall=s', 'styleall=s', 'with=s', 'extracmds=s@', 'set=s@', 'unset=s@', 'style=s{2}', 'curvestyle=s{2}', 'curvestyleall=s', 'styleall=s', 'with=s', 'extracmds=s@', 'set=s@', 'unset=s@',
'square!', 'square_xy!', 'square-xy!', 'squarexy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!', 'timefmt=s', 'square!', 'square_xy!', 'square-xy!', 'squarexy!', 'hardcopy=s', 'maxcurves=i', 'monotonic!', 'timefmt=s',
'equation=s@', 'equation=s@',
@ -168,7 +173,7 @@ sub interpretCommandline
} }
# expand options that are given as comma-separated lists # expand options that are given as comma-separated lists
for my $listkey (qw(histogram y2)) for my $listkey (qw(histogram x2 y2 x1y2 x2y1 x2y2))
{ {
@{$options{$listkey}} = map split('\s*,\s*', $_), @{$options{$listkey}} @{$options{$listkey}} = map split('\s*,\s*', $_), @{$options{$listkey}}
if defined $options{$listkey}; if defined $options{$listkey};
@ -192,6 +197,11 @@ sub interpretCommandline
@{$options{$listkey}} = @out; @{$options{$listkey}} = @out;
} }
# handle x2 == x2y1 and y2 == x1y2
push @{$options{x2y1}}, @{$options{x2}} if defined $options{x2};
push @{$options{x1y2}}, @{$options{y2}} if defined $options{y2};
$options{x2} = [];
$options{y2} = [];
# convert all tuplesize business to rangesize # convert all tuplesize business to rangesize
my $domainsize = $options{'3d'} ? 2 : 1; my $domainsize = $options{'3d'} ? 2 : 1;
@ -351,9 +361,11 @@ sub interpretCommandline
exit -1; exit -1;
} }
if ( defined $options{y2min} || defined $options{y2max} || @{$options{y2}} ) if ( defined $options{x2min} || defined $options{x2max} ||
defined $options{y2min} || defined $options{y2max} ||
@{$options{x1y2}} || @{$options{x2y1}} || @{$options{x2y2}} )
{ {
print STDERR "--3d does not make sense with --y2...\n"; print STDERR "--3d does not make sense with --x2... or --y2...\n";
exit -1; exit -1;
} }
@ -749,9 +761,10 @@ sub mainThread
print PIPE "set grid\n"; print PIPE "set grid\n";
print(PIPE "set xlabel \"$options{xlabel }\"\n") if defined $options{xlabel}; print(PIPE "set xlabel \"$options{xlabel }\"\n") if defined $options{xlabel};
print(PIPE "set x2label \"$options{x2label}\"\n") if defined $options{x2label};
print(PIPE "set ylabel \"$options{ylabel }\"\n") if defined $options{ylabel}; print(PIPE "set ylabel \"$options{ylabel }\"\n") if defined $options{ylabel};
print(PIPE "set zlabel \"$options{zlabel }\"\n") if defined $options{zlabel};
print(PIPE "set y2label \"$options{y2label}\"\n") if defined $options{y2label}; print(PIPE "set y2label \"$options{y2label}\"\n") if defined $options{y2label};
print(PIPE "set zlabel \"$options{zlabel }\"\n") if defined $options{zlabel};
print(PIPE "set title \"$options{title }\"\n") if defined $options{title}; print(PIPE "set title \"$options{title }\"\n") if defined $options{title};
if($options{square}) if($options{square})
@ -800,8 +813,9 @@ sub mainThread
} }
} }
# For the values requested to be printed on the y2 axis, set that addCurveOption($_, 'axes x1y2') foreach (@{$options{x1y2}});
addCurveOption($_, 'axes x1y2') foreach (@{$options{y2}}); addCurveOption($_, 'axes x2y1') foreach (@{$options{x2y1}});
addCurveOption($_, 'axes x2y2') foreach (@{$options{x2y2}});
# timefmt # timefmt
if( $options{timefmt} ) if( $options{timefmt} )
@ -818,7 +832,14 @@ sub mainThread
setCurveAsHistogram( $_ ) foreach (@{$options{histogram}}); setCurveAsHistogram( $_ ) foreach (@{$options{histogram}});
if(@{$options{y2}}) if(@{$options{x2y1}} || @{$options{x2y2}})
{
print PIPE "set xtics nomirror\n";
print PIPE "set x2tics\n";
# if any of the ranges are given, set the range
sendRangeCommand( "x2range", $options{x2min}, $options{x2max} );
}
if(@{$options{x1y2}} || @{$options{x2y2}})
{ {
print PIPE "set ytics nomirror\n"; print PIPE "set ytics nomirror\n";
print PIPE "set y2tics\n"; print PIPE "set y2tics\n";
@ -1831,10 +1852,10 @@ plot I<only> histograms or I<only> I<non>-histograms.
=item =item
C<--xmin/xmax/ymin/ymax/y2min/y2max/zmin/zmax xxx> C<--xmin/xmax/x2min/x2max/ymin/ymax/y2min/y2max/zmin/zmax xxx>
Set the range for the given axis. These x-axis bounds are ignored in a streaming Set the range for the given axis. These x-axis bounds are ignored in a streaming
plot. The y2-axis bound do not apply in 3d plots. The z-axis bounds apply plot. The x2/y2-axis bounds do not apply in 3d plots. The z-axis bounds apply
I<only> to 3d plots or colormaps. Note that there is no C<--xrange> to set both I<only> to 3d plots or colormaps. Note that there is no C<--xrange> to set both
sides at once or C<--xinv> to flip the axis around: anything more than the sides at once or C<--xinv> to flip the axis around: anything more than the
basics supported in this option is clearly obtainable by talking to gnuplot, for basics supported in this option is clearly obtainable by talking to gnuplot, for
@ -1842,23 +1863,29 @@ instance C<--set 'xrange [20:10]'> to set the given inverted bounds.
=item =item
C<--xlabel/ylabel/y2label/zlabel xxx> C<--xlabel/x2label/ylabel/y2label/zlabel xxx>
Label the given axis. The y2-axis label does not apply to 3d plots while the Label the given axis. The x2/y2-axis labels do not apply to 3d plots while the
z-axis label applies I<only> to 3d plots. z-axis label applies I<only> to 3d plots.
=item =item
C<--y2 xxx> C<--x2/--y2/--x1y2/--x2y1/--x2y2 xxx>
Plot the data specified by this curve ID on the y2 axis. Without C<--dataid>, By default data is plotted against the x1 and y1 axes (the left and bottom one
the ID is just an ordered 0-based index. Does not apply to 3d plots. Can be respectively). If we want a particular curve plotted against a different axis,
passed multiple times, or passed a comma-separated list. By default the y2-axis we can specify that with these options. You pass C<--AXIS ID> where C<AXIS>
curves look the same as the y-axis ones. I.e. the viewer of the resulting plot defines the axis (C<x2> or C<y2> or C<x1y2> or C<x2y1> or C<x2y2>) and the C<ID>
has to be told which is which via an axes label, legend, etc. Prior to version is the curve ID. C<--x2> is a synonym for C<--x2y1> and C<--y2> is a synonym for
1.25 of feedgnuplot the curves plotted on the y2 axis were drawn with a thicker C<--x1y2>. The curve ID is an ordered 0-based index or a specific ID if
line. This is no longer the case, but that behavior can be brought back by C<--dataid> or C<--vnlog>. None of these apply to 3d plots. Can be passed
passing something like multiple times for different curve IDs, multiple IDs can be passed in as a
comma-separated list. By default the curves plotted against the various axes
aren not drawn in any differentiated way: the viewer of the resulting plot has
to be told which is which via an axes label, legend, colors, etc. Prior to
version 1.25 of C<feedgnuplot> the curves plotted on the y2 axis were drawn with
a thicker line. This is no longer the case, but that behavior can be brought
back by passing something like
--y2 curveid --style curveid 'linewidth 3' --y2 curveid --style curveid 'linewidth 3'

View File

@ -41,17 +41,24 @@ complete -W \
--timefmt \ --timefmt \
--title \ --title \
--version \ --version \
--x2 \
--y2 \
--x2y1 \
--x1y2 \
--x2y2 \
--xlabel \ --xlabel \
--xlen \ --xlen \
--xmax \ --xmax \
--xmin \ --xmin \
--y2 \ --x2label \
--y2label \ --x2max \
--y2max \ --x2min \
--y2min \
--ylabel \ --ylabel \
--ymax \ --ymax \
--ymin \ --ymin \
--y2label \
--y2max \
--y2min \
--zlabel \ --zlabel \
--zmax \ --zmax \
--zmin \ --zmin \

View File

@ -10,6 +10,7 @@ _arguments -S
'--points' \ '--points' \
'--circles' \ '--circles' \
'--xlabel:X-axis label:' \ '--xlabel:X-axis label:' \
'--x2label:X2-axis label:' \
'--ylabel:Y-axis label:' \ '--ylabel:Y-axis label:' \
'--y2label:Y2-axis label:' \ '--y2label:Y2-axis label:' \
'--zlabel:Z-axis label:' \ '--zlabel:Z-axis label:' \
@ -18,13 +19,19 @@ _arguments -S
'(--3d)--xlen[the size of the x-window to plot]:window size:' \ '(--3d)--xlen[the size of the x-window to plot]:window size:' \
'(--xlen)--xmin:min X:' \ '(--xlen)--xmin:min X:' \
'(--xlen)--xmax:max X:' \ '(--xlen)--xmax:max X:' \
'--x2min:min X2:' \
'--x2max:max X2:' \
'--ymin:min Y:' \ '--ymin:min Y:' \
'--ymax:max Y:' \ '--ymax:max Y:' \
'--y2min:min Y2:' \ '--y2min:min Y2:' \
'--y2max:max Y2:' \ '--y2max:max Y2:' \
'--zmin:min Z:' \ '--zmin:min Z:' \
'--zmax:max Z:' \ '--zmax:max Z:' \
'*--y2:plot to place on the Y2 axis:' \ '*--x2:curve to place on the X2Y1 axis:' \
'*--y2:curve to place on the X1Y2 axis:' \
'*--x2y1:curve to place on the X2Y1 axis:' \
'*--x1y2:curve to place on the X1Y2 axis:' \
'*--x2y2:curve to place on the X2Y2 axis:' \
'(--with)--curvestyleall[Additional styles for ALL curves]:style' \ '(--with)--curvestyleall[Additional styles for ALL curves]:style' \
'(--with)--styleall[Additional styles for ALL curves]:style' \ '(--with)--styleall[Additional styles for ALL curves]:style' \
'(--curvestyleall)--with[Additional styles for ALL curves]:style' \ '(--curvestyleall)--with[Additional styles for ALL curves]:style' \