最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Why Cannot Matplotlib Library Produce Me a Normal Graph? I Keep Getting a Disfigured Image - Stack Overflow

programmeradmin4浏览0评论

I am using PyCharm 2023.2.3 and Python 3.12. The following code

import matplotlib.pyplot as plt  
import numpy as np

xs = np.array([100, 500])  
ys = np.array([300, 800])

plt.plot(xs, ys)  
plt.show()

gives me the following output:

Every time I try to reinstall and run matplotlib again, it keeps showing the same issue.

I am using PyCharm 2023.2.3 and Python 3.12. The following code

import matplotlib.pyplot as plt  
import numpy as np

xs = np.array([100, 500])  
ys = np.array([300, 800])

plt.plot(xs, ys)  
plt.show()

gives me the following output:

Every time I try to reinstall and run matplotlib again, it keeps showing the same issue.

Share Improve this question edited Jan 21 at 9:20 rbaleksandar 9,68110 gold badges94 silver badges180 bronze badges asked Jan 20 at 5:48 Aleksandr ErshovAleksandr Ershov 111 bronze badge 3
  • Please provide PyCharm version. The issue appears to be related to the rending, which may be from PyCharm itself or your graphics drivers. Can you try rendering an image using PIL (Pillow) or similar library? – rbaleksandar Commented Jan 20 at 5:50
  • Thanks for the comment. PyCharm version is 2023.2.3 I have just noticed. It might be the issue. – Aleksandr Ershov Commented Jan 20 at 6:24
  • Yeah, this is most likely a PyCharm bug. Try disabling PyCharm's "SciView". – AKX Commented Jan 21 at 15:49
Add a comment  | 

1 Answer 1

Reset to default 0

Perhaps you can try to use Py-Plot's object-oriented environment, by substituting as follows:

import matplotlib.pyplot as plt
import numpy as np

xs = np.array([100, 500])
ys = np.array([300, 800])

fig, ax = plt.subplots() ax.plot(xs,ys)

I dont know if it will help you, but I have also had trouble with my graphs coming out all ascii-art like.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论