0

result

   year  Month  Min_days    Avg_days    Median_days     Count MonthName-Year
    2015   1          9        12.56          10         4     2015-Jan
    2015   2          10       13.67          9          3     2015-Feb
   ........................................................
    2016   12       12       15.788           19          2    2016-Dec
    and so on...

I created a line plot plotting min_days, avg_days, median_days, count according to month and year say. Code used for that(which works perfectly):

import matplotlib.pyplot as plt
from matplotlib import dates as mdates

result = freq_start_month_year_to_date_1(df,'Jan','2015','Dec','2019')

result['Date'] = pd.to_datetime(result[['Year', 'Month']].assign(Day=1))

# Plot the data
fig, ax = plt.subplots(figsize=(10, 2))
for col in ['Min_days','Avg_days','Median_days','Count']:
    ax.plot(result['Date'], result[col], label=col)

years = mdates.YearLocator()    # only print label for the years
months = mdates.MonthLocator()  # mark months as ticks
years_fmt = mdates.DateFormatter('%Y')

ax.xaxis.set_major_locator(years)
ax.xaxis.set_minor_locator(months)
ax.xaxis.set_major_formatter(years_fmt)

ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))

Now I want to be able to see the data while hovering over it in the plot. Any idea how to do that?

Parfait
  • 104,375
  • 17
  • 94
  • 125
noob
  • 3,601
  • 6
  • 27
  • 73
  • 1
    Look into the plotly package – Chris Jan 06 '20 at 18:56
  • 1
    https://stackoverflow.com/questions/7908636/possible-to-make-labels-appear-when-hovering-over-a-point-in-matplotlib – Pygirl Jan 06 '20 at 18:56
  • `bokeh` is pretty good - have a listen to [this](https://talkpython.fm/episodes/show/222/interactive-graphs-with-bokeh-and-python) podcast on Talk Python to Me – Umar.H Jan 06 '20 at 19:03

0 Answers0