I'm new to data science and I'm trying to plot the stock ohlc from a csv file which has data from 2000 to 2020.
I'd like to show the year on the x-axis but it only shows the month. How can I only show the year?
I'd also like to revert and limit the year of the stock price because in the csv file the date starts from 2020 and goes all the way down to 2000. I want to limit the time frame that pandas reads from the csv. for example from 2019-01 to 2020-01. This is what I have written so far:
file = r"C:\Users\Aryan\Desktop\myData.csv"
data = pd.read_csv(file)
data.timestamp = pd.to_datetime(data.timestamp, format="%Y/%m/%d")
data.info()
data.timestamp
data = data.set_index('timestamp')
When I plot the data using matplotlib and mplfinance I get this result:
mpf.plot(data['2019-10':'2020-1'], type='candle',
figratio=(30,15),
title='Some stock price',
tight_layout=True,
style = 'yahoo',
mav=(20), volume=True)
For example I want the Jan 28, 00:00 and all other timestamps look like Jan 28, 2020.