improve some TA plots

This commit is contained in:
didier
2021-03-28 23:53:33 +01:00
parent bd1f24e135
commit 3f701e4fc7
2 changed files with 6 additions and 7 deletions

View File

@@ -87,18 +87,16 @@ def ema(l_args, s_ticker, s_interval, df_stock):
plt.xlim(df_stock["4. close"].index[0], df_stock["4. close"].index[-1])
plt.xlabel("Time")
plt.ylabel(f"Share Price of {s_ticker} ($)")
axTa = axPrice.twinx()
plt.plot(df_ta.index, df_ta.values)
plt.plot(df_ta.index, df_ta.values, c="tab:blue")
l_legend = list()
l_legend.append(s_ticker)
# Pandas series
if len(df_ta.shape) == 1:
l_legend = [f"{ns_parser.n_length} EMA"]
l_legend.append(f"{ns_parser.n_length} EMA")
# Pandas dataframe
else:
l_legend = df_ta.columns.tolist()
l_legend.append(df_ta.columns.tolist())
plt.legend(l_legend)
axTa.set_ylabel("{ns_parser.n_length} EMA", color="tab:blue")
axTa.spines["right"].set_color("tab:blue")
axTa.tick_params(axis="y", colors="tab:blue")
plt.grid(b=True, which="major", color="#666666", linestyle="-")
plt.minorticks_on()
plt.grid(b=True, which="minor", color="#999999", linestyle="-", alpha=0.2)

View File

@@ -224,6 +224,7 @@ def aroon(l_args, s_ticker, s_interval, df_stock):
plt.subplot(313)
plt.plot(df_ta.index, df_ta.iloc[:, 2].values, "b", lw=2)
plt.xlim(df_stock.index[0], df_stock.index[-1])
plt.xlabel("Time")
plt.legend([f"Aroon OSC ({df_ta.columns[2]})"])
plt.grid(b=True, which="major", color="#666666", linestyle="-")