python - Matplotlib's autoscale doesn't seem to work on y axis for small values? -
for reason, plt.autoscale not seem work small values (i.e. 1e-05). displayed close 0 axis in graph shown.
any ideas going wrong here?
import matplotlib.pyplot plt y= [1.09e-05, 1.63e-05, 2.45e-05, 3.59e-05, 5.09e-05, 6.93e-05, 9.07e-05] x= [0, 10, 20, 30, 40, 50, 60] fig3, ax3 = plt.subplots() ax3.scatter(x, y, color='k', marker = "o") ax3 = plt.gca() plt.autoscale(enable=true, axis="y", tight=false) plt.show()
i believe a known issue still not solved in matplotlib. same here or here.
possible solutions case be
use plot
instead of scatter
.
import matplotlib.pyplot plt y= [1.09e-05, 1.63e-05, 2.45e-05, 3.59e-05, 5.09e-05, 6.93e-05, 9.07e-05] x= [0, 10, 20, 30, 40, 50, 60] fig3, ax3 = plt.subplots() ax3.plot(x, y, color='k', marker = "o", ls="") ax3.autoscale(enable=true, axis="y", tight=false) plt.show()
use invisible plot
in addition scatter
import matplotlib.pyplot plt y= [1.09e-05, 1.63e-05, 2.45e-05, 3.59e-05, 5.09e-05, 6.93e-05, 9.07e-05] x= [0, 10, 20, 30, 40, 50, 60] fig3, ax3 = plt.subplots() ax3.scatter(x, y, color='k', marker = "o") ax3.plot(x, y, color='none') ax3.relim() ax3.autoscale_view() plt.show()
manually scale axis using set_ylim
.
import matplotlib.pyplot plt y= [1.09e-05, 1.63e-05, 2.45e-05, 3.59e-05, 5.09e-05, 6.93e-05, 9.07e-05] x= [0, 10, 20, 30, 40, 50, 60] fig3, ax3 = plt.subplots() ax3.scatter(x, y, color='k', marker = "o") dy = (max(y) - min(y))*0.1 ax3.set_ylim(min(y)-dy, max(y)+dy) plt.show()
Comments
Post a Comment