Witam. Mam tu kod programu, który wyświetla mi wykres (x - data, y - cena). W załączniku jest zdjęcie tego, co otrzymuje (oraz dane na wszelki wypadek).
Czy ktoś wie, jak można go pokorygować, by tej części, którą oznaczyłam czarnym prostokątem na zdjęciu, pozbyć się, tzn. zrobić wykres bardziej estetycznym w tej części? Z góry dziękuję! :)
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import matplotlib.dates as dates
def pc_Ind(file, N):
data_pd = pd.read_csv(file, parse_dates=[['Date','Time']])
format = '%m/%d/%Y %H:%M'
data_pd = data_pd.set_index(data_pd['Date_Time'])
data_pd['Date_Time'] = pd.to_datetime(data_pd['Date_Time'], format=format)
data_pd = data_pd.set_index(data_pd['Date_Time'])
data_pd = data_pd.drop(columns='Date_Time')
ub = np.zeros(data_pd.shape[0])
lb = np.zeros(data_pd.shape[0])
for i in range(N - 1, data_pd.shape[0]):
ub[i] = np.max(data_pd['Close'][i-N+1:i+1])
lb[i] = np.min(data_pd['Close'][i-N+1:i+1])
fig = plt.figure(figsize=(10, 5))
fig.add_axes()
ax = fig.add_subplot(111)
ax.xaxis.grid(True, which='minor')
appl = mpatches.Patch(color='blue', label='Apple data')
upb = mpatches.Patch(color='yellow', label='PC indicator (upper)')
lwb = mpatches.Patch(color='red', label='PC indicator (lower)')
plt.legend(handles=[appl, upb, lwb])
plt.plot(data_pd.index, data_pd['Close'],'b')
plt.plot(data_pd.index, ub + 5, 'y')
plt.plot(data_pd.index, lb - 5, 'r')
plt.plot(data_pd.index, np.zeros(data_pd.shape[0]),'g')
ax.set(title='Apple', ylabel='Close price', xlabel='Datetime')
date_formatter = dates.DateFormatter('%m/%d/%Y')
ax.xaxis.set_major_formatter(date_formatter)
ax.xaxis.set_major_locator(dates.DayLocator(interval=40))
plt.setp(ax.xaxis.get_majorticklabels(), rotation=90, fontsize=7)
fig.autofmt_xdate()
ax.autoscale_view()
plt.grid()
plt.show()
return data_pd
pc_Ind('appl.csv', 14)
#Upper Band = Highest price in the last n periods
#Lower Band = Lowest price in the last n periods
- apple1.png (55 KB) - ściągnięć: 118
- appl.csv (47 KB) - ściągnięć: 190