How to make a chart with 3 y-axes using matplotlib in python

Поделиться
HTML-код
  • Опубликовано: 19 дек 2021
  • 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')
  • НаукаНаука

Комментарии • 22

  • @musabosman2843
    @musabosman2843 2 года назад +1

    Great work!, truly appreciate your work. Looking forward to your next python /matplotlip video s

  • @waheedbhatti0
    @waheedbhatti0 Год назад

    Simple and straightforward, thank you

  • @vahidmirhosseinian6560
    @vahidmirhosseinian6560 Год назад

    Very very useful video, simple & clear.Thank you!

  • @faizd1330
    @faizd1330 Год назад +1

    Great work. kindly appreciated. very easy to follow and well explained at each stages.

  • @markcsizmadia2109
    @markcsizmadia2109 4 месяца назад

    Very nice solution, learned something new thanks!

  • @mohammedbadaway7490
    @mohammedbadaway7490 2 года назад

    thank you , your explain is very awesome

  • @jiahuey9375
    @jiahuey9375 2 года назад

    this really helps!! thanks alot!!!!!!!

  • @safrullahsafrullah7999
    @safrullahsafrullah7999 2 года назад

    Very helpful...thanks

  • @marialuisaargaezsalcido4957
    @marialuisaargaezsalcido4957 Год назад

    Thank you very much!!!! blessings

  • @mdimranq
    @mdimranq 2 года назад

    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

  • @marialaurita77
    @marialaurita77 Год назад

    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!!

  • @8848nepalyt
    @8848nepalyt Год назад

    Thank you so much.

  • @user-dn4om5wl6z
    @user-dn4om5wl6z 2 года назад

    شكرا جزيلاً اختي العزيزة

  • @user-888azim-97
    @user-888azim-97 2 года назад

    have we got the same for js ??

  • @Superworldhk
    @Superworldhk Год назад

    Matplotlib can plot 1 Xaxie and 6 y-axies?

  • @soso83169
    @soso83169 11 месяцев назад

    How can i add legend title to this type of code?

  • @ishanrama8540
    @ishanrama8540 Год назад

    Thx!!!

  • @googl824
    @googl824 29 дней назад

    how can make map of track of altimetry satellite

  • @paulinamelena9936
    @paulinamelena9936 3 месяца назад

    Can we make this for x?

  • @megarestuutari7195
    @megarestuutari7195 2 года назад

    Thank you it helps me a lot :))