Hey there! i was looking all around the internet for a problem in plottng a candlestick-graph from database using python this is the code, can anyone help me because im still unable to figure it out
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
import numpy as np
from mpl_finance import candlestick_ohlc
import MySQLdb
db = MySQLdb.connect(host="localhost", user="root", passwd="root", db="toroi")
cur=db.cursor()
cur.execute('SELECT DATE,CLOSE FROM btc_csv')
fig=plt.figure()
graph=fig.set_facecolor('white')
alch_N=[]
alch_m=[]
alch_p=[]
alch_c=[]
alch_d=[]
alch_a=[]
for row in cur.fetchall():
DATE=str(row[0])
print("the total data is ",row)
CLOSE=str(row[1])
print("the total data is β,row)
HIGH=str(row[3])
print("the total data is β,row)
LOW=str(row[4])
print("the total data is β,row)
CLOSE=str(row[5])
print("the total data is β,row)
ADJ_CLOSE=str(row[6])
print("the total data is β,row)
alch_N.append(DATE)
alch_m.append(OPEN)
alch_p.append(HIGH)
alch_c.append(LOW)
alch_d.append(CLOSE)
alch_a.append(ADJ_CLOSE)
ohlc= db[['Date', 'Open', 'High', 'Low','Close']].copy()
f1, ax = plt.subplots(figsize = (10,5))
candlestick_ohlc(ax, ohlc.values, width=.6, colorup='green', colordown='red')
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m'))
plt.savefig('OHLC FORD.png')
plt.show()
cur.close()
db.close()