3

I run code from this answer How to put the legend out of the plot in PyCharm in console (Anaconda environment) and it didn't produced right output

I recreated a conda env, but it still does not work.

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()

Expected: what's presented in answer.

Actual in PyCharm (SciView) pycharm Actual in prompt prompt

Eskapp
  • 3,419
  • 2
  • 22
  • 39

0 Answers0