How to make a chart with 3 y-axes using matplotlib in python
Вставка
- Опубліковано 4 лют 2025
- import matplotlib.pyplot as plt
fig, ax1 = plt.subplots()
years = [2018,2019,2020,2021]
first = [1,2,1,2]
second = [10,15,17,11]
third = [111,120,117,129]
ax1.plot(years,first,color="blue")
ax2 = ax1.twinx()
ax2.plot(years,second,color="green")
ax3 = ax1.twinx()
ax3.plot(years,third,color="red")
#ax3.spines['right'].set_position(('outward',60))
ax3.spines['right'].set_position(('axes',1.15))
ax1.set_ylabel("First",color="blue")
ax2.set_ylabel("Second",color="green")
ax3.set_ylabel("Third",color="red")
ax1.tick_params(axis='y',colors="blue")
ax2.tick_params(axis='y',colors="green")
ax3.tick_params(axis='y',colors="red")
ax2.spines['right'].set_color("green")
ax3.spines['right'].set_color("red")
ax3.spines['left'].set_color("blue")
plt.show()
#fig.tight_layout()
fig.savefig("3-axis-v3.png",bbox_inches='tight')
Great work!, truly appreciate your work. Looking forward to your next python /matplotlip video s
Great work. kindly appreciated. very easy to follow and well explained at each stages.
Simple and straightforward, thank you
Very nice solution, learned something new thanks!
Very very useful video, simple & clear.Thank you!
Thanks a lot for your explanation!
Very well explained and very useful! How would you make the distance between marks of the 3 axes the same? (for example, that the width between marks is 1 cm). I can't find a way to solve it. thank you!!
Hello\ pls tell me how to restart Endnotes from each chapter in MS 2007? I have to complete the thesis. I want to insert Endnotes at the end of the Introduction only, but when I insert them, it goes to the end of the thesis. How to solve this problem. pls tell
Matplotlib can plot 1 Xaxie and 6 y-axies?
Thank you very much!!!! blessings
thank you , your explain is very awesome
How can i add legend title to this type of code?
have we got the same for js ??
Can we make this for x?
how can make map of track of altimetry satellite
Thank you it helps me a lot :))
Very helpful...thanks
شكرا جزيلاً اختي العزيزة
Thank you so much.
this really helps!! thanks alot!!!!!!!
Thx!!!