  C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD # matplotlib change Axis scale  » python » matplotlib change Axis scale

By : Helal Uddin
Date : November 17 2020, 11:55 AM
this one helps. The extent parameter alters the ticks displayed on the imshow plot. The extent should be passed a 4-tuple or list with the following meaning: extent=(xmin, xmax, ymin, ymax). The y-axis can be inverted by passing origin='lower' to imshow. code :
``````import numpy as np
import matplotlib.pyplot as plt

mydata = np.random.random((10,10))

im = plt.imshow(mydata,interpolation='bilinear', aspect='auto',
origin='lower', extent=[0, 1, 0, 1])
plt.colorbar(im, orientation='vertical')
plt.show()
`````` ## Matplotlib - fixing x axis scale and autoscale y axis

By : Koren Leslie Cohen
Date : March 29 2020, 07:55 AM
With these it helps Autoscaling always uses the full range of the data, so the y-axis is scaled by full extent of the y-data, not just what's within the x-limits.
If you'd like to display a subset of the data, then it's probably easiest to plot only that subset:
code :
``````import numpy as np
import matplotlib.pyplot as plt

x, y = np.arange(0,101,1) ,300 - 0.1*np.arange(0,101,1)
mask = (x >= 50) & (x <= 100)

fig, ax = plt.subplots()

plt.show()
`````` ## Fix scale for x-axis matplotlib

By : shashankk215r
Date : March 29 2020, 07:55 AM
seems to work fine You can try set_xlim() (called AFTER the plot) This should force your x-axis to stay between 0.5 and 1, and I believe it will scale it automatically.
code :
``````set_xlim(0.5,1)
`````` ## Axis scale will not change with matplotlib

By : Misha
Date : March 29 2020, 07:55 AM
Your code actually is working. if you look at the values ax.get_xlim() you will see the boundaries you set. ## change x axis scale im matplotlib imshow?

By : user3523924
Date : March 29 2020, 07:55 AM
help you fix your problem The code is giving me the image below. I need to have more precision in the x-axis. Now I have next points in every 100 samples. But I'd love to have printed points more often(at each 50 samples). , You can set the axis locator in the following way:
code :
``````x = np.linspace(0,200,10)
y = x**2
fig, ax = plt.subplots()

ax.plot(x,y)
``````
``````import matplotlib.ticker as plticker
fig, ax = plt.subplots()

ax.plot(x,y)

loc = plticker.MultipleLocator(base=50)
ax.xaxis.set_major_locator(loc)
`````` ## Matplotlib scale y axis based on manually zoomed x axis

By : Alexandra Fournier
Date : March 29 2020, 07:55 AM
I wish this help you Based on the comment from mdurant I wrote some minimal example as a starting point for you: 