简体   繁体   中英

Pandas.DataFrame.plot() problems with axes values

This is the .head() of my DataFrame:

                 Open    High    Low     Close    Volume     Market Cap
Date                        
Apr 09, 2018    7044.32 7178.11 6661.99 6770.73 4894060000  119516000000
Apr 08, 2018    6919.98 7111.56 6919.98 7023.52 3652500000  117392000000
Apr 07, 2018    6630.51 7050.54 6630.51 6911.09 3976610000  112467000000
Apr 06, 2018    6815.96 6857.49 6575.00 6636.32 3766810000  115601000000
Apr 05, 2018    6848.65 6933.82 6644.80 6811.47 5639320000  116142000000

& the statement to plot the 'Close' over the DateIndex:

plot = df['Close'].plot()

By default the x-axis is labeled with 'Date' but no DateValues are shown.How to adjust this?
The y-axis is not labeled but the CloseValues are shown with intervals i also want to adjust.

Found no solution :( Thx for help as always!

Make the index a DatetimeIndex :

df.index = pd.to_datetime(df.index)

df.Close.plot()

在此处输入图片说明

piRSquared's answer is correct (as usual). You can also do this in one line using

matplotlib.pyplot.plot(pd.to_datetime(df.index), df.Close);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM