[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #46484] datetick does not "keeplimits"
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #46484] datetick does not "keeplimits" |
Date: |
Fri, 20 Nov 2015 19:43:50 +0000 |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0 |
URL:
<http://savannah.gnu.org/bugs/?46484>
Summary: datetick does not "keeplimits"
Project: GNU Octave
Submitted by: None
Submitted on: Fr 20 Nov 2015 19:43:49 UTC
Category: Plotting
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: None
Assigned to: None
Originator Name: Lars K.
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Any
_______________________________________________________
Details:
When datetick() is called with the "keeplimits" argument it should conserve
the xlim resp. ylim property of the axis. That is the intended behavior and
also what matlab does. At the moment, however, datetick.m always recalculates
the limits based on the data. As a result it is not possible to reapply date
labels after zooming in either from the gui or calling the xlim() or ylim()
function:
t0=datenum('2015-01-01');
t=t0:1/1440:t0+30; %one month
x=sin(2*pi*(t-t0));
plot(t,x)
datetick x
disp "press enter to show one week only!"
pause
xlim([t0 t0+7]);
disp "press enter to apply datetick again!"
pause
datetick x keeplimits
%this will rescale to full data limits
This patch will fix it:
diff -r a5949b3d2332 scripts/plot/appearance/datetick.m
--- a/scripts/plot/appearance/datetick.m Thu Nov 19 14:39:04 2015 -0800
+++ b/scripts/plot/appearance/datetick.m Fri Nov 20 19:51:30 2015 +0100
@@ -144,18 +144,24 @@
else
## Need to do our own axis tick position calculation as
## year, etc, don't fallback on nice datenum values.
- objs = findall (gca ());
- xmax = NaN;
- xmin = NaN;
- for i = 1 : length (objs)
- fld = get (objs (i));
- if (isfield (fld, [ax "data"]))
- xdata = getfield (fld, [ax "data"])(:);
- xmin = min (xmin, min (xdata));
- xmax = max (xmax, max (xdata));
- endif
- endfor
-
+ if (keeplimits)
+ limits=get (gca (), [ax "lim"]);
+ xmin=limits(1);
+ xmax=limits(2);
+ else
+ objs = findall (gca ());
+ xmax = NaN;
+ xmin = NaN;
+ for i = 1 : length (objs)
+ fld = get (objs (i));
+ if (isfield (fld, [ax "data"]))
+ xdata = getfield (fld, [ax "data"])(:);
+ xmin = min (xmin, min (xdata));
+ xmax = max (xmax, max (xdata));
+ endif
+ endfor
+ endif
+
if (isnan (xmin) || isnan (xmax))
xmin = 0;
xmax = 1;
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?46484>
_______________________________________________
Nachricht gesendet von/durch Savannah
http://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-bug-tracker] [bug #46484] datetick does not "keeplimits",
anonymous <=