Secondary axis and twin axis in python matplotlib plots

preview_player
Показать описание


Please subscribe, like and share this video

#python #matplotlib #dev #tutorial #learning #beginners #pythonforbeginners #taming_python #plotting
Рекомендации по теме
Комментарии
Автор

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

bennguyen