New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
normalizeAxis now scales the input data with respect to the view area. #1034
base: develop
Are you sure you want to change the base?
Conversation
No shift of data is computed.
From a quick look at the code, what I think has changed is: I currently fail to see how this improves the situation, so could you elaborate and/or show an example (preferably with a picture or something illustrative). My intuition tells me we should use XLim (etc.) and not the full data, since one may have a lot outside the active axis limits. |
Using the YLim [-inf inf] for automatic scaling fails in the current solution. This was the originally indication for me to change this. It furthermore allows scaling to zoomed views, which the original mode does not. |
Hmm, indeed, once one of the XYZLims is not finite, our current code will not do anything sensible; which should indeed be fixed (but I am a bit unsure whether this more complicated approach is the best way forward, especially since you mention quite a bit of it is still experimental). |
I'm not well familiar with 3d plots. My implementation will fail trying to scale a 3d plot with automatic scaling. But the current implementation doesn't have a solution for this either. E.g. plotting deviations of a something or sines with mean not being zero. The mean must be kept, but scaled. |
I fail to see how negative data breaks by subtracting the lower limit (of the visible view). Could you show an example? By glancing at the code, for negative data, I still expect the visible part of the data to be mapped to the range Basically, what our current code tries to do is come up with a translation and scaling of the data, such that the visible data falls in the range |
In my testcase I used a plot with 5 Line Objects in R2017a. If the original purpose of the code is the above, I misunderstood the meaning of it. See example below for behaviour: t=(0:0.001:0.2).';
y=2e-4*sin(2*pi*10*t)+0.8e-4*sin(2*pi*20*t);
y=y+0.1e-4*randn(length(y),1);
figure;
plot(t,y)
%%
hfig=figure;
plot(t,y)
cleanfigure('handle',hfig,'normalizeAxis','Y'); Your result: [-2,+3] |
Sorry for getting back after such a long time, I have not taken a lot of time lately to look at m2t since I don't use it that often anymore. Anyway, I think there is a misunderstanding going on here: the goal of the axis normalization is to rescale the backing data in your axis to a more sensible range (i.e. the data stored in However, in the case you bring up, something is indeed not going the way it should: there is this little scale at the top of the Y axis which is not properly accounted for in our code (this is On one hand, the implementation that you propose is sub-optimal in a few aspects:
So on our end, I see a few actions associated with this:
For that last point, I think indeed an approach like yours is a valid approach:
But it needs to be done in a reliable way; while one can just as well set the limits by hand. So I'm not really convinced whether it is worth the additional work and complexity (since to handle zoomed plots, as you pint out, you somehow need to couple to the concrete Line/... classes since you do index into the data, and the code is implicitly assuming that Y depends on X (and that Y contains Inf in the limits), which is not how everybody's plots work). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above. TL;DR:
- breaks current functionality,
- is really complicated to handle a small edge case that can be worked around easily.
No shift of data is computed.
This modified procedure significantly improves the outcome for 2d plots. It adds support to zoomed views of multiple datasets and limits the data to the spanwidth.