Secondary axis and twin axis in python matplotlib plots

Поделиться
HTML-код
  • Опубликовано: 19 авг 2023
  • Blog post for this video - nagasudhir.blogspot.com/2023/...
    Playlist URL - • Matplotlib plotting in...
    Intro to Matplotlib, terminology, simple line plot - • Matplotlib Introductio...
    Basic styling of Matplotlib plots - • Basic styling of Matpl...
    Multiple Plots in a same subplot using Matplotlib - • Multiple line plots in...
    Grid of multiple subplots in a Matplotlib figure - • Grid of multiple subpl...
    Export Matplotlib figure as image/pdf - • Export Matplotlib figu...
    Introduction to Pandas DataFrame and simple initialization - • Pandas DataFrame Intro...
    Table of contents - nagasudhir.blogspot.com/2020/...
    Please subscribe, like and share this video
    #python #matplotlib #dev #tutorial #learning #beginners #pythonforbeginners #taming_python #plotting
  • НаукаНаука

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

  • @bennguyen1313
    @bennguyen1313 7 месяцев назад

    I understand that a 2nd series of data, with it's own scale can be done using twinx..
    ax2 = ax1.twinx()
    But you can create another spine (with different scaling) for either of the y data using:
    ax1b = ax1.secondary_yaxis
    ax2b = ax2.secondary_yaxis
    But what if you have 3 completely independent series you want to plot.. with no function/relationship between them? For example, If ax1 is centigrade, ax2 is sales, then how can a new ax3 and its legend "Ghost", replace the Fahrenheit axis (i.e. to the left most side of the figure)?
    ax3 = ax1.twinx()
    ax3.spines['left'].set_position(('axes',0.01)) # places new spine to the right of ax1
    ax3.spines['left'].set_position(('axes',-1)) # places new spine to the right of the ax2