matplotlib中有沒有任何方法來保持勾選位置均勻,而保持它們的值不均勻,以便數據可能擠壓一些間隔,並可能在另一個間隔上展開。 例如下面的代碼生成與蜱正弦波[0.0,0.5,1.0,1.5,2.0]matplotlib - 均勻保持勾號位置,但值不均勻
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2*np.pi*t)
plt.plot(t, s)
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)
ax = plt.gca()
ax.get_xaxis().get_major_formatter().set_useOffset(False)
plt.autoscale(False)
ax.xaxis.set_ticks([0.0,0.5,1.0,1.5,2.0])
plt.show()
我想在ax.xaxis.set_ticks爲值0.5變爲0.25([0.0,0.5,1.0 ,1.5,2.0]),但保持在圖上的相同位置。
您需要提供至少一個你想要達到什麼樣的手繪製樣機。正如下面的答案所示,你想要的是完全不清楚的。 –
這是https://stackoverflow.com/questions/32185411/break-in-x-axis-of-matplotlib你在找什麼?在x軸的1/4處繪製0-0.25,在剩餘的3/4處從0.25-2.0繪製? –