0

I want to manually switch the offset power-of-10 multiplication on and off for matplotlib plots, like it is automatically adjusted in the picture for both x- and y-axis.

enter image description here

My code:

# circle with radius pert_max[j,eps]

phi = np.linspace(0,2*np.pi,100)  
plt.plot(pert_max[j,eps]*np.cos(phi) ,pert_max[j,eps]*np.sin(phi),'k--',alpha=.5 )
        
# plot eigenvalue data from EValues[j][:,eps,:]

plt.plot(np.real(EValues[j][:,eps,:]), np.imag(EValues[j][:,eps,:]), marker='.', ls='', ms=3, c='k')

# visible window
window = pert_max[j,eps]*1.1

#x-axis
plt.xlim(-window, window)
plt.xlabel(r'$\Re(\lambda)$')

#y-axis
plt.ylim(-window, window)
plt.ylabel(r'$\Im(\lambda)$')

plt.gca().set_aspect('equal', adjustable='box')
plt.tight_layout(pad=0.1)
plt.show()

For increasing values, the labels change to 0.0001 notation instead of putting the order of magnitude on the axis. How can I manually control this? Thanks in advance

etkm
  • 13
  • 3

1 Answers1

0

For anyone wanting to not only suppress the orders of magnitude, but to place them where it is unsual to use them, the margin for their automatic use (data < 10^(-n) or data > 10^m) can be set by:


fmt=ScalarFormatter(useOffset=True)
fmt.set_scientific(True)
fmt.set_powerlimits((n, m))

plt.gca().yaxis.set_major_formatter(fmt)

etkm
  • 13
  • 3