qbdj

matplotlib绘图时是默认的大小,有时候默认的大小会感觉图片里的内容都被压缩了,解决方法如下。
先是原始代码:

from matplotlib import pyplot as plt

plt.figure(figsize=(1,1))

x = [1,2,3]
plt.plot(x, x)
plt.show()

  

关键的代码是plt.figure(figsize=(1,1)),生成的图片如下

修改代码,放大图片:

from matplotlib import pyplot as plt

plt.figure(figsize=(10,10))

x = [1,2,3]
plt.plot(x, x)
plt.show()

  

这时候横坐标和纵坐标都放大了10倍:

如果想要指定像素,可以这么做:

from matplotlib import pyplot as plt

plt.figure(dpi=80)

x = [1,2,3]
plt.plot(x, x)
plt.show()

  

 

原文:https://blog.csdn.net/zhangpeterx/article/details/90734660

 

分类:

技术点:

相关文章:

  • 2021-09-29
  • 2021-11-23
  • 2021-11-06
  • 2021-10-18
  • 2021-12-04
  • 2021-10-17
猜你喜欢
  • 2021-11-22
  • 2021-10-07
  • 2021-11-24
  • 2021-12-23
  • 2021-11-21
  • 2021-11-14
相关资源
相似解决方案