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
  • Наука та технологія

КОМЕНТАРІ • 21

  • @joseantonioubeira295
    @joseantonioubeira295 2 роки тому

    Thank you so much for this very helpful tutorial ! It was a real lifesaver, as all your other videos !

  • @giorgiozampaglione8849
    @giorgiozampaglione8849 2 роки тому

    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?

  • @alexanderhall1819
    @alexanderhall1819 3 роки тому

    Great content. You move very fluidly through your examples. Def recommending channel to other students in my data science program

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому

      Glad you enjoyed it and thanks for the recommendation!

  • @amanpatyal2187
    @amanpatyal2187 3 роки тому

    always useful basic bits ....✔✨👏

  • @BrunoAraujo-po2lm
    @BrunoAraujo-po2lm 3 роки тому

    Awesoooome, give moooooore! ^^

  • @AkshitMadan
    @AkshitMadan 3 роки тому

    Good explanation ma'am 👍

  • @furqanakramsheikh8999
    @furqanakramsheikh8999 2 роки тому

    You are amazing mam Kimberly Fessel.

  • @MonicaAlvarez-ls6nc
    @MonicaAlvarez-ls6nc 3 роки тому

    Great, this is so useful! Can you make a video of subplots and double axe graph. Thanks for your work.

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому

      Very glad to hear you enjoy it. And good suggestions! I will put of these on my list 😄

  • @nicksharafeddin7347
    @nicksharafeddin7347 3 роки тому +1

    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) ?

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому +1

      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)

    • @nicksharafeddin7347
      @nicksharafeddin7347 3 роки тому

      @@KimberlyFessel Thank you very much.

  • @priyanshusaxena7157
    @priyanshusaxena7157 3 роки тому

    Please make more videos like this...

  • @rajatgupta7344
    @rajatgupta7344 3 роки тому

    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??

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому

      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)