Тёмный

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

Kimberly Fessel
Подписаться 20 тыс.
Просмотров 15 тыс.
50% 1

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:
github.com/kimfetti/Videos/bl...
Related Videos:
* Introduction to SEABORN: • Introduction to Seabor...
* Matplotlib Tips PLAYLIST: • Matplotlib Tips
#matplotlib #dataviz

Наука

Опубликовано:

 

29 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 45   
@salmansiddiqui9502
@salmansiddiqui9502 21 день назад
Thank you. I initially came to learn how `twinx` works, but I ended up learning a lot of other helpful things as well. I'm subscribing 🙂.
@KimberlyFessel
@KimberlyFessel 21 день назад
Awesome! Welcome aboard! 👍
@youcefyahiaoui1465
@youcefyahiaoui1465 2 года назад
Kimberly, I think you should be given a noble price of teaching. I love your way of driving the concepts home, your energy and your enthusiasm. You're the best.
@nicholasrice1748
@nicholasrice1748 Год назад
Was hung up on the legend overlapping for a bit, thanks
@sandfly2830
@sandfly2830 2 года назад
Extraordinary!!! I love how you explain everything concisely. Thank you very much for the video ❤️
@KimberlyFessel
@KimberlyFessel 2 года назад
So glad you enjoyed the video and found it concise -- cheers! 😄
@heliumbite91
@heliumbite91 2 года назад
Thank you for the clear and precise tutorials!
@KimberlyFessel
@KimberlyFessel 2 года назад
Most welcome - it's amazing all the things that Matplotlib can do!
@joseantonioubeira295
@joseantonioubeira295 2 года назад
Excellent video ! Very clear and informative as always.. thank you so much for this Tips series !
@KimberlyFessel
@KimberlyFessel 2 года назад
Most welcome! Glad you enjoyed this video and series 😄
@vitorribeirosa
@vitorribeirosa 10 месяцев назад
Neat!!!! Thank you so much for sharing this content. It really made my life easier here. Cheers!!!!
@antonleshchuk5908
@antonleshchuk5908 Год назад
Many thanks for this tutorial!
@bvatbdsubfigv
@bvatbdsubfigv 2 года назад
Really great tutorial!📈
@sashaaries21
@sashaaries21 Год назад
So helpful. Thank you.
@renatocorreaarrieche
@renatocorreaarrieche Год назад
Amazing video!
@jas0609
@jas0609 2 года назад
Thank you so much! This is a big help!
@KimberlyFessel
@KimberlyFessel 2 года назад
Awesome - and thank YOU for asking this question!! 😄
@davidjackson7675
@davidjackson7675 Год назад
Thanks , that was interesting.
@anggipermanaharianja6122
@anggipermanaharianja6122 2 года назад
this is very useful one!
@ahsanulhaq6064
@ahsanulhaq6064 2 года назад
great video keep it up 👍
@nilakanthasahoo798
@nilakanthasahoo798 Год назад
Thanks it helped! w.r.t time = 6:43 Just adding another tip for someone in future (maybe myself :D) Rather than using 'labelcolor' in ax.tickparams(), you could use 'colors' to set the ticks along with the label to the same color instead of the default black Cheers!
@vfx7t
@vfx7t 2 года назад
Thank you !
@victoralcantar8004
@victoralcantar8004 2 года назад
Great information, thanks.
@KimberlyFessel
@KimberlyFessel 2 года назад
Most welcome!
@vijaygusain119
@vijaygusain119 2 года назад
Beautifully explained by a beautiful lady👏
@KimberlyFessel
@KimberlyFessel 2 года назад
💁 Thanks very much -- glad to hear you enjoyed my explanation!
@maheshnaik8388
@maheshnaik8388 Год назад
very informative,,,
@ksawerylejczak6975
@ksawerylejczak6975 2 года назад
Your videos are the best I've ever seen in this field, but I have a question: have You thought about making videos which showing plotly library? It would be amazing in Your performance. Cheers :)
@KimberlyFessel
@KimberlyFessel 2 года назад
Oh thanks so much! 😄Yes, I have been considering tackling the Plotly library for quite some time. Hopefully I will get to it soon!
@MM-jx3rw
@MM-jx3rw Год назад
Kimberly, is there a way to connect the data points of the spines to each other? For example, if I have a data of 10 rows and 4 columns. In which each column is a separate y axis with its own scale while each row is a single observation, is there a way to connect the data points of a single observation with a line even though they have separate y axis?
@jullienbeaufondcamacho2055
@jullienbeaufondcamacho2055 4 месяца назад
Super nice explanation
@KimberlyFessel
@KimberlyFessel 4 месяца назад
Thanks very much! Glad you liked it 😊
@felicytatomaszewska2934
@felicytatomaszewska2934 2 года назад
Great :)
@KimberlyFessel
@KimberlyFessel 2 года назад
Thank you! Cheers! 😄
@houriabraikia417
@houriabraikia417 2 года назад
Hello, can you please do a video about bias and variance, you have a good way of explanation. Thank you :)
@KimberlyFessel
@KimberlyFessel 2 года назад
Great idea! I will add this to my list of potential video topics. 😄
@ThaFuzzwood
@ThaFuzzwood 2 года назад
How do you prevent the figure from expanding horizontally when using twinx? I set my figure dimensions in the main figure, let's say 8.4 by 6.2 centimeters. The first figure is added as a subplot, and the twinx is added to this subplot. Without the twinx, the figure nicely scales to 8.4 to 6.2 cm as desired. When adding the twinx, the figure expands by at least 1 extra cm.
@KimberlyFessel
@KimberlyFessel 2 года назад
You're right - the figure size will be a bit different with the new axis since you have added axis tick markers. One thing that can help a bit is adding a line of code at the end of your figure: plt.tight_layout()
@ahsanulhaq6064
@ahsanulhaq6064 2 года назад
can you make a video or update code at your Github for how to split single y-axis in two portions۔ for example plot X and its square on the same axis with partition
@Niconico2
@Niconico2 2 года назад
Thanks for this Video, but why the line does not start at the x = 0 | y = 0 when you define the variable x and y with linespace(0,100,1000), the 0 is included as a x[0] and y[0] but i can not udnestand why when i plot it the line start after a space, i know it is a 0,0 in the chart, but how can i fix this?. Is my question clear? haha Thx!
@Niconico2
@Niconico2 2 года назад
Fixed with axes.set_xlim([0,x.max()]) axes.set_ylim([0,z.max()]) but i dont know if that is the idea.
@ndeye4599
@ndeye4599 Год назад
Hii mam could you show the samething in a subplot?
Далее
I Built 100 Homes And Gave Them Away!
09:36
Просмотров 42 млн
Crazy Girl destroy RC CARS 👩🤪🚘🚨
00:20
Просмотров 4,2 млн
The Python Function You NEED For 2D Data
10:49
Просмотров 35 тыс.
How to: Plot a Function in Python
13:47
Просмотров 120 тыс.
Seaborn Is The Easier Matplotlib
22:39
Просмотров 161 тыс.
🛑 STOP! SAMSUNG НЕ ПОКУПАТЬ!
1:00
Просмотров 85 тыс.