Scoping x and y limits simultaneously

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Scoping x and y limits simultaneously

Fritz Sonnichsen
I am processing a rather large dataset and want to create and zoom
various plots. I am easily able to zoom the x axis using the axis([x1
x2]) type command. However when I do this I need to re-normalize the y
limits to fill the plot.
       At present I have a rather lengthy script that finds the min and
max y values within the new range , retrieve their indices,  and then
divides all the y values.

However I was thinking there is a better way to do this as such:

data=load('C:\@fnsonset\sensors\gases\spectra\testdata.csv');
plot(data(:,1),data(:,2));
axis([20 30]);
ylim auto

This does not work. The "auto" mandate scopes the y across the complete
range, not just the scoped down range.

Is there a way to do this without my scripts?

thanks
Fritz


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Scoping x and y limits simultaneously

Kire Pudsje


On Fri, Jun 9, 2017 at 7:07 PM, Fritz Sonnichsen <[hidden email]> wrote:
I am processing a rather large dataset and want to create and zoom various plots. I am easily able to zoom the x axis using the axis([x1 x2]) type command. However when I do this I need to re-normalize the y limits to fill the plot.
      At present I have a rather lengthy script that finds the min and max y values within the new range , retrieve their indices,  and then divides all the y values.

However I was thinking there is a better way to do this as such:

data=load('C:\@fnsonset\sensors\gases\spectra\testdata.csv');
plot(data(:,1),data(:,2));
axis([20 30]);
ylim auto

This does not work. The "auto" mandate scopes the y across the complete range, not just the scoped down range.

Is there a way to do this without my scripts?

I think it would be hard to implement in a generic way, since although most plots use a monotonic increasing x-axis, this does not have to be the case. Also if the limits of x and y are not aligned with the data, the intersection of all segments that cross the limits should be interpolated.

Why not just create plots with a subset of the data?
ss=(20 <= data(:,1)) & (data(:,1) <= 30);
plot(data(ss,1), data(ss,2));


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Scoping x and y limits simultaneously

Fritz Sonnichsen
Thanks for the reply. I was assuming the more common case of an increasing x. In general the domain for a given range is deterministic.

My reason for avoiding the subset method was simply that I am dealing with large datasets and I assume that Octave actually copies the selected records into the new variable.

thanks again
fritz

On 6/9/2017 2:13 PM, Kire Pudsje wrote:


On Fri, Jun 9, 2017 at 7:07 PM, Fritz Sonnichsen <[hidden email]> wrote:
I am processing a rather large dataset and want to create and zoom various plots. I am easily able to zoom the x axis using the axis([x1 x2]) type command. However when I do this I need to re-normalize the y limits to fill the plot.
      At present I have a rather lengthy script that finds the min and max y values within the new range , retrieve their indices,  and then divides all the y values.

However I was thinking there is a better way to do this as such:

data=load('C:\@fnsonset\sensors\gases\spectra\testdata.csv');
plot(data(:,1),data(:,2));
axis([20 30]);
ylim auto

This does not work. The "auto" mandate scopes the y across the complete range, not just the scoped down range.

Is there a way to do this without my scripts?

I think it would be hard to implement in a generic way, since although most plots use a monotonic increasing x-axis, this does not have to be the case. Also if the limits of x and y are not aligned with the data, the intersection of all segments that cross the limits should be interpolated.

Why not just create plots with a subset of the data?
ss=(20 <= data(:,1)) & (data(:,1) <= 30);
plot(data(ss,1), data(ss,2));



_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave