同じ図で2つの異なる関数をプロットしたいとします。しかし、彼らは彼らのx軸に異なるスケールを使用したい。 1つの目盛りはxの値を表示するだけで、他のものは最後に秒を表示する必要があります。同じ図の2つの関数を2つのx軸に異なる縮尺でプロットする
は、今私は、私は申し訳ありませんが、この
k=5
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.set_xlabel(r"values of x") #adds description to scale on bottom
ax2 = ax1.twiny() #adds the seconds scale on top
x = np.arange(0.1, 1.5, 0.1) #values of x for function are in range
y = k*(np.power(x,(k-1))) * np.exp(-(np.power(x,(k-1)))) #that is the function I want to draw
ax1.plot(x,y) #draw function
tx = x
ty = x*7
ax2.plot(x,x*7)
ax2.set_xlabel(r"time in seconds")
ax2.set_xlim(1484) #set limit of time
ax2.invert_xaxis() #invert it so that it works like we want to
ax1.set_xlim(0.1,1.4) #set limit for the x axis so that it doesn't skale on its own.
plt.show()
持っているが、私は適切にコードを挿入することができませんでした。 ax2関数は今やちょうどダミーです。私はそれを見ることができるだけでなく、最後にax2のスケールを私の時間枠に変えたいと思っています。
ご協力いただければ幸いです!