mirror of
https://github.com/dkogan/feedgnuplot.git
synced 2025-05-06 06:21:16 +08:00
added --autolegend option to generate the legends from curve IDs
This commit is contained in:
parent
4dfb086e96
commit
54fc148ed0
@ -68,6 +68,8 @@ As an example, if line 3 of the input is "0 9 1 20"
|
|||||||
--legend xxx Set the label for a curve plot. Give this option multiple
|
--legend xxx Set the label for a curve plot. Give this option multiple
|
||||||
times for multiple curves
|
times for multiple curves
|
||||||
|
|
||||||
|
--autolegend Use the curve IDs for the legend
|
||||||
|
|
||||||
--xlen xxx Set the size of the x-window to plot. Omit this or set it
|
--xlen xxx Set the size of the x-window to plot. Omit this or set it
|
||||||
to 0 to plot ALL the data
|
to 0 to plot ALL the data
|
||||||
|
|
||||||
@ -144,6 +146,7 @@ GetOptions(\%options,
|
|||||||
'lines!',
|
'lines!',
|
||||||
'points!',
|
'points!',
|
||||||
'legend=s@',
|
'legend=s@',
|
||||||
|
'autolegend!',
|
||||||
'xlabel=s',
|
'xlabel=s',
|
||||||
'ylabel=s',
|
'ylabel=s',
|
||||||
'y2label=s',
|
'y2label=s',
|
||||||
@ -507,10 +510,13 @@ sub updateCurveOptions
|
|||||||
# case. When no title is specified, gnuplot will still add a legend entry with an unhelpful '-'
|
# case. When no title is specified, gnuplot will still add a legend entry with an unhelpful '-'
|
||||||
# label. Thus I explicitly do 'notitle' for that case
|
# label. Thus I explicitly do 'notitle' for that case
|
||||||
|
|
||||||
my ($curveoptions) = @_;
|
my ($curveoptions, $id) = @_;
|
||||||
my $titleoption = defined $curveoptions->{title} ?
|
|
||||||
"title \"$curveoptions->{title}\"" : "notitle";
|
|
||||||
|
|
||||||
|
my $title;
|
||||||
|
$title = $curveoptions->{title} if(defined $curveoptions->{title});
|
||||||
|
$title = $id if $options{autolegend};
|
||||||
|
|
||||||
|
my $titleoption = defined $title ? "title \"$title\"" : "notitle";
|
||||||
$curveoptions->{options} = "$curveoptions->{extraoptions} $titleoption";
|
$curveoptions->{options} = "$curveoptions->{extraoptions} $titleoption";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,7 +539,7 @@ sub getCurve
|
|||||||
push @curves, [{extraoptions => ' '}]; # push a curve with no data and no options
|
push @curves, [{extraoptions => ' '}]; # push a curve with no data and no options
|
||||||
$curveIndices{$id} = $#curves;
|
$curveIndices{$id} = $#curves;
|
||||||
|
|
||||||
updateCurveOptions($curves[$#curves][0]);
|
updateCurveOptions($curves[$#curves][0], $id);
|
||||||
}
|
}
|
||||||
return $curves[$curveIndices{$id}];
|
return $curves[$curveIndices{$id}];
|
||||||
}
|
}
|
||||||
@ -544,7 +550,7 @@ sub addCurveOption
|
|||||||
|
|
||||||
my $curve = getCurve($id);
|
my $curve = getCurve($id);
|
||||||
$curve->[0]{extraoptions} .= "$str ";
|
$curve->[0]{extraoptions} .= "$str ";
|
||||||
updateCurveOptions($curve->[0]);
|
updateCurveOptions($curve->[0], $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub setCurveLabel
|
sub setCurveLabel
|
||||||
@ -553,7 +559,7 @@ sub setCurveLabel
|
|||||||
|
|
||||||
my $curve = getCurve($id);
|
my $curve = getCurve($id);
|
||||||
$curve->[0]{title} = $str;
|
$curve->[0]{title} = $str;
|
||||||
updateCurveOptions($curve->[0]);
|
updateCurveOptions($curve->[0], $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
# function to add a point to the plot. Assumes that the curve indexed by $idx already exists
|
# function to add a point to the plot. Assumes that the curve indexed by $idx already exists
|
||||||
|
Loading…
Reference in New Issue
Block a user