Add a baseline to a matplotlib figure || Horizontal and vertical lines || Matplotlib Tips
Вставка
- Опубліковано 21 лип 2024
- Learn how to create a matplotlib baseline including a horizontal line and a vertical line with this Matplotlib Tips tutorial. I demonstrate how to use pyplot's axhline function to create a matplotlib horizontal line and the matplotlib axvline function to make a vertical line. I also show you how to use ymin and ymax to truncate the line. I explain why adding a baseline is important with a few examples, and then I walk you through several line styling properties including changing color, updating matplotlib axhline thickness, creating a dashed line, and layering multiple lines with zorder. Finally, I show you how to create a legend by setting axhline label and labeling each other line of your matplotlib figure.
0:00 Introduction
0:10 Horizontal & Vertical Lines
1:18 Baseline Explanation Figures
1:39 Line Styling
3:47 Conclusion
Github Code:
github.com/kimfetti/Videos/bl...
Related Videos:
How to change the matplotlib FIGURE SIZE: • How to change the matp...
How to SAVE a matplotlib figure: • How to save a matplotl...
#matplotlib #dataviz #matplotlibtips - Наука та технологія
Thank you so much for this very helpful tutorial ! It was a real lifesaver, as all your other videos !
So glad to hear it was helpful - cheers!
This is such a helpful video! Thank you so much! One question, could you do the same but using a datetime object instead of a scalar?
Great content. You move very fluidly through your examples. Def recommending channel to other students in my data science program
Glad you enjoyed it and thanks for the recommendation!
always useful basic bits ....✔✨👏
Thanks! 😄
Awesoooome, give moooooore! ^^
You got it! More videos coming up 😄
Good explanation ma'am 👍
Thank you! 👍
You are amazing mam Kimberly Fessel.
Great, this is so useful! Can you make a video of subplots and double axe graph. Thanks for your work.
Very glad to hear you enjoy it. And good suggestions! I will put of these on my list 😄
Thank you very much for very helpful, and informative virtual lecture.
I just would like to ask a question, if I may,
Could we plot the vertical line with at the last point of a moving curve ( such as in stock curve) ?
Glad to hear it was helpful! You're interested in plotting a vertical line that depends on a variable? Sure, you should be able to do this. If you can extract the last point of your moving curve and save it to a Python variable, you can just submit that variable to matplotlib. For example: my_var = ..... Then put that variable into the function: plt.axvline(my_var)
@@KimberlyFessel Thank you very much.
Please make more videos like this...
Will do!
Hi, @Kimberly I came across a problem where we have to count the number of male and female using a single column of dataframe and plot the graph for the same. (means using a categorical column)
1.x=titanic.Sex.value_counts()
a=x.index
b=x.values
sns.barplot(a,b)
2.plt.bar(a,b)
is there better way then this 2 in a single line code??
I might just use pandas plotting for this. titanic.Sex.value_counts.plot(kind='bar') should work. Or you could create a column of all ones and then switch your estimator to numpy's sum... sns.barplot(x = titantic.Sex, y=np.ones(len(titantic.Sex)), estimator=np.sum)