Jan-11-2023, 03:00 PM
Hey there python community, after successfully plotting a graph, when it comes to plotting the frontier of it, I get this message:
ValueError: x and y must have same first dimension, but have shapes (1,) and (50,)This is the graph:
plt.figure(figsize=(22,7))
plt.scatter(expectedVolatility,expectedReturn,c=sharpeRatio)
plt.xlabel('expected volatility')
plt.ylabel('expected log returns')
plt.colorbar(label='sharpe ratio')
plt.scatter(expectedVolatility[maxIndex],expectedReturn[maxIndex],c='red')
plt.plot(volatility_opt,returns, '--')
plt.show()I know this kind of error is very common and in my humble opinion probably it arises from here:returns = np.linspace(0, 1.50, num= 50, endpoint=True, retstep=False, dtype=None, axis=0) volatility_opt = []and the output is
volatility_opt [10.194341397342678]as the volatility_opt shouldn't be obviously just one value. I can't find yet precisely the origin, where could it be?
