0

This is my code. I looked at the documentation but didn't find the answer.

 import pandas as pd
 import matplotlib.pyplot as plt
 from datetime import datetime
 avs = pd.read_csv('daily_2004_2014.csv')
 avs = avs.set_index(pd.DatetimeIndex(avs['Date']))
 fig = plt.figure()
 avs.plot()
 plt.show()

Here is the generated image

1 Answer 1

1

The plot function returns axes.

axes = avs.plot()

Then you can edit the axes in any way you want. In your case

axes.set_ylabel('Desired Label')
Sign up to request clarification or add additional context in comments.

4 Comments

Actually, I have another question. How to remove the automatically generated x-axis label 'Date' in the generated image above?
Essentially the same question. Just set the label to nothing axes.set_xlabel(' ')
Thanks, and I have another question. The generated plot shows x-axis tick labels for every alternate year 2004, 2006, 2008, ... Is there a way to show labels for every major tick i.e., 2004, 2005, 2006, 2007, ....., 2014?
You are going to want to use axes.set_xticks() and/or ax.set_xticklabels(). You may also want fig.autofmt_xdate(). This is all pretty basic plotting which is likely answered elsewhere, you should search around for these answers harder and read the documentation of the functions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.