diff --git a/gamestonk_terminal/comparison_analysis/yahoo_finance_api.py b/gamestonk_terminal/comparison_analysis/yahoo_finance_api.py index 31d2c662a21..edd3e726d4d 100644 --- a/gamestonk_terminal/comparison_analysis/yahoo_finance_api.py +++ b/gamestonk_terminal/comparison_analysis/yahoo_finance_api.py @@ -6,11 +6,11 @@ import matplotlib.pyplot as plt import yfinance as yf import seaborn as sns -from gamestonk_terminal.helper_funcs import parse_known_args_and_warn +from gamestonk_terminal.helper_funcs import parse_known_args_and_warn, plot_autoscale +from gamestonk_terminal.config_plot import PLOT_DPI register_matplotlib_converters() - d_candle_types = { "o": "Open", "h": "High", @@ -79,7 +79,7 @@ def historical(l_args, df_stock, s_ticker, s_start, s_interval, similar): similar += ns_parser.l_also - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.title(f"Similar companies to {s_ticker}") df_stock = yf.download(s_ticker, start=s_start, progress=False) plt.plot( diff --git a/gamestonk_terminal/prediction_techniques/arima.py b/gamestonk_terminal/prediction_techniques/arima.py index 5ed5b4e45b7..e68ac8aad8b 100644 --- a/gamestonk_terminal/prediction_techniques/arima.py +++ b/gamestonk_terminal/prediction_techniques/arima.py @@ -11,6 +11,7 @@ from gamestonk_terminal.helper_funcs import ( valid_date, patch_pandas_text_adjustment, get_next_stock_market_days, + plot_autoscale, ) from gamestonk_terminal.prediction_techniques.pred_helper import ( print_pretty_prediction, @@ -18,6 +19,7 @@ from gamestonk_terminal.prediction_techniques.pred_helper import ( print_prediction_kpis, ) +from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal import feature_flags as gtff register_matplotlib_converters() @@ -168,7 +170,7 @@ def arima(l_args, s_ticker, df_stock): print("") # Plotting - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.plot(df_stock.index, df_stock["5. adjusted close"], lw=2) if ns_parser.s_order: # BACKTESTING @@ -241,7 +243,7 @@ def arima(l_args, s_ticker, df_stock): # BACKTESTING if ns_parser.s_end_date: - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.subplot(211) plt.plot( df_future.index, diff --git a/gamestonk_terminal/prediction_techniques/ets.py b/gamestonk_terminal/prediction_techniques/ets.py index a802b0cc977..96e17306d78 100644 --- a/gamestonk_terminal/prediction_techniques/ets.py +++ b/gamestonk_terminal/prediction_techniques/ets.py @@ -11,6 +11,7 @@ from gamestonk_terminal.helper_funcs import ( valid_date, patch_pandas_text_adjustment, get_next_stock_market_days, + plot_autoscale, ) from gamestonk_terminal.prediction_techniques.pred_helper import ( print_pretty_prediction, @@ -18,6 +19,7 @@ from gamestonk_terminal.prediction_techniques.pred_helper import ( print_prediction_kpis, ) +from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal import feature_flags as gtff register_matplotlib_converters() @@ -179,7 +181,7 @@ def exponential_smoothing(l_args, s_ticker, df_stock): print(f"SSE: {round(model.sse, 2)}\n") # Plotting - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.plot(df_stock.index, df_stock["5. adjusted close"], lw=2) # BACKTESTING if ns_parser.s_end_date: @@ -249,7 +251,7 @@ def exponential_smoothing(l_args, s_ticker, df_stock): # BACKTESTING if ns_parser.s_end_date: - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.subplot(211) plt.plot( df_future.index, diff --git a/gamestonk_terminal/prediction_techniques/fbprophet.py b/gamestonk_terminal/prediction_techniques/fbprophet.py index 21447c7d1ca..e2294791b6c 100644 --- a/gamestonk_terminal/prediction_techniques/fbprophet.py +++ b/gamestonk_terminal/prediction_techniques/fbprophet.py @@ -11,12 +11,14 @@ from gamestonk_terminal.helper_funcs import ( parse_known_args_and_warn, valid_date, patch_pandas_text_adjustment, + plot_autoscale, ) from gamestonk_terminal.prediction_techniques.pred_helper import ( price_prediction_backtesting_color, print_prediction_kpis, ) +from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal import feature_flags as gtff register_matplotlib_converters() @@ -114,7 +116,7 @@ def fbprophet(l_args, s_ticker, df_stock): ] # .apply(lambda x: f"{x:.2f} $") df_pred.index = l_pred_days - _, ax = plt.subplots() + _, ax = plt.subplots(figsize=plot_autoscale(), dpi=PLOT_DPI) model.plot( forecast[: -ns_parser.n_days], ax=ax, @@ -177,7 +179,7 @@ def fbprophet(l_args, s_ticker, df_stock): # BACKTESTING if ns_parser.s_end_date: - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.subplot(211) plt.plot( df_future.index, diff --git a/gamestonk_terminal/prediction_techniques/knn.py b/gamestonk_terminal/prediction_techniques/knn.py index 584c6f73d80..bd515d5ac45 100644 --- a/gamestonk_terminal/prediction_techniques/knn.py +++ b/gamestonk_terminal/prediction_techniques/knn.py @@ -11,6 +11,7 @@ from gamestonk_terminal.helper_funcs import ( valid_date, patch_pandas_text_adjustment, get_next_stock_market_days, + plot_autoscale, ) from gamestonk_terminal.prediction_techniques.pred_helper import ( print_pretty_prediction, @@ -18,7 +19,7 @@ from gamestonk_terminal.prediction_techniques.pred_helper import ( print_prediction_kpis, ) - +from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal import feature_flags as gtff register_matplotlib_converters() @@ -143,7 +144,7 @@ def k_nearest_neighbors(l_args, s_ticker, df_stock): df_pred = pd.Series(l_predictions, index=l_pred_days, name="Price") # Plotting - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.plot(df_stock.index, df_stock["5. adjusted close"], lw=2) # BACKTESTING if ns_parser.s_end_date: @@ -202,7 +203,7 @@ def k_nearest_neighbors(l_args, s_ticker, df_stock): # BACKTESTING if ns_parser.s_end_date: - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.subplot(211) plt.plot( df_future.index, diff --git a/gamestonk_terminal/prediction_techniques/neural_networks.py b/gamestonk_terminal/prediction_techniques/neural_networks.py index 64f2c2f02c0..d8a44978b7e 100644 --- a/gamestonk_terminal/prediction_techniques/neural_networks.py +++ b/gamestonk_terminal/prediction_techniques/neural_networks.py @@ -17,6 +17,7 @@ from gamestonk_terminal.helper_funcs import ( valid_date, patch_pandas_text_adjustment, get_next_stock_market_days, + plot_autoscale, ) from gamestonk_terminal.prediction_techniques.pred_helper import ( @@ -25,7 +26,7 @@ from gamestonk_terminal.prediction_techniques.pred_helper import ( print_prediction_kpis, ) - +from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal import feature_flags as gtff from gamestonk_terminal import config_neural_network_models as cfg_nn_models @@ -275,7 +276,7 @@ def mlp(l_args, s_ticker, df_stock): df_pred = pd.Series(y_pred_test_t[0].tolist(), index=l_pred_days, name="Price") # Plotting - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.plot(df_stock.index, df_stock["5. adjusted close"], lw=3) # BACKTESTING if ns_parser.s_end_date: @@ -341,7 +342,7 @@ def mlp(l_args, s_ticker, df_stock): # BACKTESTING if ns_parser.s_end_date: - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.subplot(211) plt.plot( df_future.index, @@ -654,7 +655,7 @@ def rnn(l_args, s_ticker, df_stock): df_pred = pd.Series(y_pred_test_t[0].tolist(), index=l_pred_days, name="Price") # Plotting - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.plot(df_stock.index, df_stock["5. adjusted close"], lw=3) # BACKTESTING if ns_parser.s_end_date: @@ -720,7 +721,7 @@ def rnn(l_args, s_ticker, df_stock): # BACKTESTING if ns_parser.s_end_date: - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.subplot(211) plt.plot( df_future.index, @@ -1033,7 +1034,7 @@ def lstm(l_args, s_ticker, df_stock): df_pred = pd.Series(y_pred_test_t[0].tolist(), index=l_pred_days, name="Price") # Plotting - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.plot(df_stock.index, df_stock["5. adjusted close"], lw=3) # BACKTESTING if ns_parser.s_end_date: @@ -1099,7 +1100,7 @@ def lstm(l_args, s_ticker, df_stock): # BACKTESTING if ns_parser.s_end_date: - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.subplot(211) plt.plot( df_future.index, diff --git a/gamestonk_terminal/prediction_techniques/regression.py b/gamestonk_terminal/prediction_techniques/regression.py index 947914ae496..ffdeb881cec 100644 --- a/gamestonk_terminal/prediction_techniques/regression.py +++ b/gamestonk_terminal/prediction_techniques/regression.py @@ -14,6 +14,7 @@ from gamestonk_terminal.helper_funcs import ( valid_date, patch_pandas_text_adjustment, get_next_stock_market_days, + plot_autoscale, ) from gamestonk_terminal.prediction_techniques.pred_helper import ( @@ -22,7 +23,7 @@ from gamestonk_terminal.prediction_techniques.pred_helper import ( print_prediction_kpis, ) - +from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal import feature_flags as gtff register_matplotlib_converters() @@ -163,7 +164,7 @@ def regression(l_args, s_ticker, df_stock, polynomial): df_pred = pd.Series(l_predictions, index=l_pred_days, name="Price") # Plotting - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.plot(df_stock.index, df_stock["5. adjusted close"], lw=2) # BACKTESTING if ns_parser.s_end_date: @@ -225,7 +226,7 @@ def regression(l_args, s_ticker, df_stock, polynomial): # BACKTESTING if ns_parser.s_end_date: - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.subplot(211) plt.plot( df_future.index, diff --git a/gamestonk_terminal/prediction_techniques/sma.py b/gamestonk_terminal/prediction_techniques/sma.py index 6b0504c1794..b371553343c 100644 --- a/gamestonk_terminal/prediction_techniques/sma.py +++ b/gamestonk_terminal/prediction_techniques/sma.py @@ -11,6 +11,7 @@ from gamestonk_terminal.helper_funcs import ( valid_date, patch_pandas_text_adjustment, get_next_stock_market_days, + plot_autoscale, ) from gamestonk_terminal.prediction_techniques.pred_helper import ( @@ -19,7 +20,7 @@ from gamestonk_terminal.prediction_techniques.pred_helper import ( print_prediction_kpis, ) - +from gamestonk_terminal.config_plot import PLOT_DPI from gamestonk_terminal import feature_flags as gtff register_matplotlib_converters() @@ -125,7 +126,7 @@ def simple_moving_average(l_args, s_ticker, df_stock): df_pred = pd.Series(l_predictions, index=l_pred_days, name="Price") # Plotting - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.plot(df_stock.index, df_stock["5. adjusted close"], lw=2) # BACKTESTING if ns_parser.s_end_date: @@ -189,7 +190,7 @@ def simple_moving_average(l_args, s_ticker, df_stock): # BACKTESTING if ns_parser.s_end_date: - plt.figure() + plt.figure(figsize=plot_autoscale(), dpi=PLOT_DPI) plt.subplot(211) plt.plot( df_future.index,