0

I have data of days from all days from 2004-01-01 until 2015-31-12 and want to plot the maximum and the minimun value of each day.
The original data is on df and df['Day'] is a colum with day and month.

So, I created two new dataframes:

dfmin=df.groupby('Day').agg('min')
dfmax=df.groupby('Day').agg('max')

The new dataframes has one row for each day of the year, considering the max and the minimun value for each day in the range.

I want to label the axis with each day, but without specify any year. I already saw this questions and this documentation but did not find the answer.

For example, I did:

observation_dates = np.arange('2013-01-01', '2014-01-01', dtype='datetime64[D]')
plt.plot(dfmin.index, dfmin.Data_Value)
plt.plot(dfmin.index, dfmax.Data_Value)
...

And created the following chart: enter image description here

But I would like to do something like:

observation_dates = np.arange(' -01-01', ' -01-01', dtype='datetime64[D]')
...

So the axis would be labeled just with the days, but without specifying any year

EDIT TO CLARIFY A LITTLE MORE:

After group the data by days, I got the following dataframe (represented by the blue line at the chart):

DAY     Data_Value
01-01    -160
01-02    -267
01-03    -267

I just want to plot this values using dates at x-axis

Oalvinegro
  • 458
  • 5
  • 21
  • So are you only talking about the way the labels are displayed or do you want to actually group the data by month and day? – gosuto Sep 17 '19 at 14:53
  • I already grouped the data by month and day, I just want to create an arange to label the chart – Oalvinegro Sep 17 '19 at 14:54
  • It's not obvious why you need that. If you decided that your plot has the dates from 2013, you can use 2013 in the `arange`. – ImportanceOfBeingErnest Sep 17 '19 at 15:49
  • I edited the question, explaining better what I need – Oalvinegro Sep 17 '19 at 16:08
  • I think there is a misconception. Datetimes cannot exist without date. But what you want is to only use the month for labelling, that is, you need a tick at a specific date, 2013-01-01, but that tick's label can be anything, even `"My daughter's birthday"`. Labelling is steered via `Formatters` in matplotlib. So you can use a `matplotlib.dates.DateFormatter()`. – ImportanceOfBeingErnest Sep 17 '19 at 16:21
  • You are wright, I just wnat to label in month-day format. I edited the question. I read the documentation but did not find a way – Oalvinegro Sep 17 '19 at 17:51

0 Answers0