Reputation: 1
This is more of a math question than a matplotlib question but if there is a way to do this specifically in matplotlib that would be great.
I have a set of points with the max-y-value and the min-y-value can have a difference anywhere from a few hundred to a few thousand.
I am trying to plot these points in a very small scale on the y-axis (maybe a span of 2 units).
For example, I have the points (10, 20) (11, 123) (12, 77) (13, 124) and I want to plot them inbetween the y_values of 0-2. How would I scale this down? Either mathematically or a built-in matplotlib way.
Upvotes: 0
Views: 1336
Reputation: 1393
You can just do a simple linear transformation, for all y's:
ynew= 2*(y-ymin)/(ymax-ymin)
The fraction (y-ymin)/(ymax-ymin) first gives you the percentage of the y coordinate in the range you are interested in, and then to get it from range 0-1 into range 0-2, you just multiply by 2.
Upvotes: 1