Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas: How to display minor grid lines on x-axis in pd.DataFrame.plot()

Tags:

Is there a way to control grid format when doing pandas.DataFrame.plot()?

Specifically i would like to show the minor gridlines for plotting a DataFrame with a x-axis which has a DateTimeIndex.

Is this possible through the DataFrame.plot()?

df = pd.DataFrame.from_csv(csv_file, parse_dates=True, sep=' ')
like image 773
user2846226 Avatar asked Dec 16 '13 17:12

user2846226


People also ask

How do I show a minor grid in Matplotlib?

Matplotlib doesn't show the minor ticks / grid by default so you also need explicitly show them using minorticks_on() .

How do I plot specific columns in pandas?

To plot a specific column, use the selection method of the subset data tutorial in combination with the plot() method. Hence, the plot() method works on both Series and DataFrame .

How do I change the size of my pandas plot?

The size of a plot can be modified by passing required dimensions as a tuple to the figsize parameter of the plot() method. it is used to determine the size of a figure object. Where dimensions should be given in inches.


1 Answers

Maybe this feature didn't exist last year, but in version 0.19.2 you can do:

df.plot(grid=True)

See the doc.

like image 130
Bastiaan Avatar answered Sep 20 '22 05:09

Bastiaan