我是 Python 新手,一直在尝试绘制随着时间的推移的假设回报。然而,我的投资组合价值和日期之间的间隔非常接近。
因此,有人可以提供一些有关我如何做的见解:
这是我当前的脚本和图表
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import numpy as np
import datetime as dt
import matplotlib.cbook as cbook
from matplotlib.dates import DateFormatter
df = pd.read_csv(r"C:\Production_Ports_Graphs\Prod_Ports_VS_S&P.CSV")
x1 = df["Date"]
y1 = df["Very_Bullish_Portfolio_Value"]
y2 = df["Very_Bearish_Portfolio_Value"]
y3 = df["S&P500_Portfolio_Value"]
fig, ax = plt.subplots(figsize=(12, 12))
df.set_index("Date").plot(ax=ax, x_compat=True)
ax.set_xticks(df.index)
ax.set_yticks(df["Very_Bullish_Portfolio_Value"])
ax.locator_params(axis="y", tight=True, nbins=30)
plt.gcf().autofmt_xdate()