Display Info When You Hover To A Data Point In Matplotlib (Source Code In Description)

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ต.ค. 2024
  • This is one of the most requested topics so I thought I would finally make a video showing how to implement the feature when you hover your mouse on top of a data point a data label will automatically pop up.
    📑 Source Code: wp.me/payCAw-1jR
    ► Buy Me a Coffee? Your support is much appreciated!
    -------------------------------------------------------------------------------------------
    ☕ Paypal: www.paypal.me/...
    ☕ Venmo: @Jie-Jenn
    💸 Join Robinhood with my link and we'll both get a free stock: bit.ly/3iWr7LC
    ► Support my channel so I can continue making free contents
    ---------------------------------------------------------------------------------------------------------------
    🌳 Becoming a Patreon supporter: / jiejenn
    🛒 By shopping on Amazon → amzn.to/2JkGeMD
    📘 Facebook Page → / madeinpython
    📘 More tutorial videos on my website → LearnDataAnaly...
    👩‍💻 Follow me on Linked: / jiejenn
    ✉️ Business Inquiring: TH-cam@LearnDataAnalysis.org
    #matplotlib #datavisualization #python

ความคิดเห็น • 21

  • @jumbolinowal
    @jumbolinowal 2 ปีที่แล้ว +5

    There is one problem: The hover-event shows the x-value twice. It shows (x, x) and not (x, y). It has to be like this:
    text_label = '({0:.2f}, {1:.2f})'.format(data_point_location[0], data_point_location[1])

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว +1

      I didn't notice that. Good call!

    • @vishwanathkadalagi2336
      @vishwanathkadalagi2336 11 หลายเดือนก่อน

      it still ends up showing (x,x)?

  • @ClaudioPisa-c5z
    @ClaudioPisa-c5z 6 หลายเดือนก่อน

    Do you think is possible to do so with a simple graph and not with a scatter plot ?

    • @jiejenn
      @jiejenn  6 หลายเดือนก่อน

      Definitely. You can do it with any type of graphs.

  • @star-wp7os
    @star-wp7os ปีที่แล้ว

    hi, thanks for your video.
    how can i apply this code at 3D scatter plot?
    i tried it but ....
    i made scatter like this " scatter(x,y,z) " and ran " scatter.get_offsets() ".
    result was different that i think
    how can i get (x,y,z) data?

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      I don't have much experience working with 3d graphs, I would suggest you post your question on Stack Overflow.

  • @taiwoosunrinde3927
    @taiwoosunrinde3927 ปีที่แล้ว

    Hi, I tried rer-running the code, it is throwing this error:
    Traceback (most recent call last):
    File "./prog.py", line 23, in
    TypeError: annotate() missing 1 required positional argument: 's'

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      Annotate function is missing a parameter value.

    • @taiwoosunrinde3927
      @taiwoosunrinde3927 ปีที่แล้ว

      @@jiejenn how do i solve this. It is not showing any error when you did yours. Thanks

    • @jiejenn
      @jiejenn  ปีที่แล้ว +1

      I charge a $7 fee for troubleshooting. Let me know if you still need my assistance.

    • @taiwoosunrinde3927
      @taiwoosunrinde3927 ปีที่แล้ว

      @@jiejenn for the code you wrote or the one I am trying to make work , using your approach. Just need clarification on what I will be getting

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      @@taiwoosunrinde3927 it is almost impossible to troubleshoot by looking at an error description without knowing what the code looks like. That's what I'm trying to say.

  • @rcsmit
    @rcsmit 2 ปีที่แล้ว +2

    Why not using plotly? They do it by default

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว

      I prefer matplotlib.

  • @jackingo
    @jackingo 2 ปีที่แล้ว +1

    I'm unable to do this in google colab the hover doesn't appear in it

    • @prxshetty
      @prxshetty ปีที่แล้ว

      Did you get the solution for this??? I have been stuck at the same problem too. 🥲🥲

  • @SpectacularAustin
    @SpectacularAustin 2 ปีที่แล้ว +1

    Can you make video on how to delete ALL videos on a TH-cam channel using YT API?

    • @jiejenn
      @jiejenn  2 ปีที่แล้ว

      I will look into it.

  • @philtoa334
    @philtoa334 2 ปีที่แล้ว

    Very good thx.