0

Is there a way to add tooltips to a stacked bar plot in matplotlib? I would like to use only matplotlib. My stacked bar plot has more than ten bars in each position. I would like to have a tooltip for each stacked bar. I have seen the question matplotlib-stacked-bar-chart-and-tooltip but the answer there uses mpldatacursor and I would like to use only matplotlib. In addition, I will have more than two bars in each position, as already mentioned.

What I want to achieve is shown in the figure below. The bars with less than 10% will have no label but a tooltip showing information about them. The tooltip will be displayed with a mouse hover event. enter image description here

kbr85
  • 1,416
  • 12
  • 27
  • Possible duplicate of [Matplotlib - Stacked bar chart and tooltip](https://stackoverflow.com/questions/50788421/matplotlib-stacked-bar-chart-and-tooltip) – Diziet Asahi Mar 04 '19 at 15:11
  • @Diziet Asahi. I have edited the question. I would like to use only matplotlib. In addition, I have more than two bars in each position. – kbr85 Mar 04 '19 at 15:39
  • See [this question](https://stackoverflow.com/questions/50560525/i-want-to-display-the-values-of-x-and-y-while-hover-mouse-over-the-bar-graph/50560826#50560826) for how to show annotations upon hovering with the mouse. – ImportanceOfBeingErnest Mar 04 '19 at 23:27
  • @ImportanceOfBeingErnest I am aware of the answer you mention but that did not work for my stacked bar plot. Actually, I do not know how the example in the answer works since bar does not have a contain method. – kbr85 Mar 05 '19 at 09:38

0 Answers0