我从这个答案运行代码How to put the legend out of the plot in PyCharm in console (Anaconda environment) 并且它没有产生正确的输出
我重新创建了一个 conda env,但它仍然无法正常工作。
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,2*np.pi)
colors=["#7aa0c4","#ca82e1" ,"#8bcd50","#e18882"]
fig, axes = plt.subplots(ncols=2)
for i in range(4):
axes[i//2].plot(x,np.sin(x+i), color=colors[i],label="y=sin(x+{})".format(i))
fig.legend(loc=7)
fig.tight_layout()
fig.subplots_adjust(right=0.75)
plt.show()
预期:答案中呈现的内容。
PyCharm (SciView)中的实际值提示中的
实际值