आपने गौर किया है, xscale
और yscale
एक सरल रैखिक फिर से स्केलिंग (दुर्भाग्य से) का समर्थन नहीं करता। झुका के जवाब के लिए एक विकल्प के रूप में, बजाय डेटा के साथ खिलवाड़ की, आप लेबल तो जैसे चाल कर सकते हैं:
ticks = ticker.FuncFormatter(lambda x, pos: '{0:g}'.format(x*scale))
ax.xaxis.set_major_formatter(ticks)
एक पूरा उदाहरण दोनों x और y स्केलिंग दिखा:
import numpy as np
import pylab as plt
import matplotlib.ticker as ticker
# Generate data
x = np.linspace(0, 1e-9)
y = 1e3*np.sin(2*np.pi*x/1e-9) # one period, 1k amplitude
# setup figures
fig = plt.figure()
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122)
# plot two identical plots
ax1.plot(x, y)
ax2.plot(x, y)
# Change only ax2
scale_x = 1e-9
scale_y = 1e3
ticks_x = ticker.FuncFormatter(lambda x, pos: '{0:g}'.format(x/scale_x))
ax2.xaxis.set_major_formatter(ticks_x)
ticks_y = ticker.FuncFormatter(lambda x, pos: '{0:g}'.format(x/scale_y))
ax2.yaxis.set_major_formatter(ticks_y)
ax1.set_xlabel("meters")
ax1.set_ylabel('volt')
ax2.set_xlabel("nanometers")
ax2.set_ylabel('kilovolt')
plt.show()
और अंत में मेरे पास है एक तस्वीर के लिए क्रेडिट:
ध्यान दें कि, यदि आप text.usetex: true
है के रूप में मैं है, तो आप ला संलग्न कर सकते हैं $
में बेल्स, जैसे: '${0:g}$'
।
यॉटम, आपको लगता है कि कई प्रश्न हैं जो उत्तर दिए गए हैं लेकिन आपने अभी तक जवाब स्वीकार नहीं किया है। कृपया पुराने प्रश्नों के लिए उत्तर स्वीकार करें या अतिरिक्त जानकारी जोड़ें ताकि हम आपकी मदद कर सकें! – Hooked