Matplotlib Secondary y-Axis || Add another y-axis with Matplotlib twinx || Matplotlib Tips

Опубликовано: 11 October 2024
на канале: Kimberly Fessel
15,249
376

Learn how to make a Matplotlib secondary y axis in this Matplotlib Tips tutorial video. I start from the basics and show you how to add another y axis with the matplotlib twinx axes method. I explain that you should consider matplotlib two y axes if your data are on two different scales. Then we learn how to use ax twinx, which creates a new set of subplot axes with an invisible x-axis but an independent y axis on the opposite side. I them demonstrate how you can color code your matplotlib secondary y axis ticks and label to make your visual more clear. I also show you code for creating a matplotlib secondary y axis legend, both as separate legends for each axis and as one ax twinx legend. I then walk you through an example of creating a seaborn secondary y axis, which means you can have seaborn two y axes as well also using plt twinx. Finally, I conclude by showing visuals of a matplotlib figure with three y axes and a matplotlib secondary x-axis using matplotlib twiny.

0:00 Introduction
0:18 BASICS: matplotlib twinx
4:53 COLOR CODE: labels, ticks, spines
8:10 LEGEND: ax twinx legend
10:52 SEABORN twinx
12:28 Other Options: 3 y-Axes and twiny
13:12 BLOOPERS

GitHub Code:
https://github.com/kimfetti/Videos/bl...

Related Videos:
Introduction to SEABORN:    • Introduction to Seaborn | How seaborn...  
Matplotlib Tips PLAYLIST:    • Matplotlib Tips  

#matplotlib #dataviz