zoukankan      html  css  js  c++  java
  • Python:matplotlib绘图时指定图像大小,放大图像

    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

  • 相关阅读:
    省选测试28
    省选测试27
    省选测试26
    省选测试25
    省选测试24
    省选测试23
    省选测试22
    省选测试21
    关于maven 导入依赖的最终处理问题
    Dubbo 2 之抽取公共接口
  • 原文地址:https://www.cnblogs.com/qbdj/p/11010773.html
Copyright © 2011-2022 走看看