0
votes

Let's say I have a set of data with x ranging from 0 to 5 (evenly distributed, say the spacing is 0.2), during this total x range, I actually have some fine features in terms of y values, say from 0 to 1 range. Beyond that, the features are coarse.

So now I want a figure to be like more zoomed into 0 to 1 range but still plotting out the total x range. The best scenario is of course not losing any data points.

Currently I do have one potential solution, where I pick up sparse points from the 1 to 5 range (spacing of 1 instead of 0.2) and plot out those data points evenly first. And then label with the correct corresponding x values as the following (those are just some random numbers I used here for explanation, the figure doesn't have fine features between 0 to 1 range though):

x=[0 0.2 0.4 0.6 0.8 1 2 3 4 5];
x1=0:9;
y=[0.1 0.2 0.3 0.4 0.5 1 2 3 4 5];

figure(1)
plot(x1,y,'-o')
set(gca,'xticklabel',x)

Figure plot

But this will obviously lose some information from the 1 to 5 range.

Is there a better way that I can still plot the whole range from 0 to 5 with the original data points but with a detailed showing of 0 to 1 range?

Thanks!

2

2 Answers

0
votes

Not sure I understand. What about this?

x=[0:.2:1 2 3 4 5];

y=[0.1 0.2 0.3 0.4 0.5 1 2 3 4 5];

figure(1)
plot(x,y,'-o')
0
votes

I would say the only proper way of having non-uniform intervals on the x-axis is by using a logarithmic scale. Try

semilogx(x,y,'-o')