zoukankan      html  css  js  c++  java
  • matplotlib ax 与 刻度相关函数

    参考链接
    https://blog.csdn.net/weixin_34498545/article/details/112631706
    
    
    进行初始化
    
    plt.figure(figsize = (8,6))
    
    ax = plt.gca()

    调整坐标轴范围
    
    x轴
    ax.set_xlim()
    
    
    y轴
    ax.set_ylim()
    
    设置在 0 - 8 之间
    ax.set_xlim(0,8)
    
    ax.set_ylim(0,8)

    设置 x 轴 y 轴 标题
    ("内容",fontsize = ,color = ,alpha = , bbox = ,)
    
    
    ax.set_xlabel()
    
    
    ax.set_ylabel()
    
    
    参数示例
    
    ax.set_xlabel("X轴",fontsize = 14,color = 'b',alpha = 0.7,bbox=dict(boxstyle='round,pad=0.5', fc='yellow', ec='blue',lw=1 ,alpha=0.7))
    
    ax.set_ylabel("Y轴",fontsize = 14,color = 'b',alpha = 0.7,bbox=dict(boxstyle='round,pad=0.5', fc='yellow', ec='blue',lw=1 ,alpha=0.7))

    修改默认刻度文字
    (列表 , family = , fontsize = ,)
    
    ax.set_xticklabels()
    
    
    ax.set_yticklabels()
    
    
    ax.set_xticklabels(['A','B','C','D','E','F','G'])
    
    ax.set_yticklabels(['','','','','','',''],
    family = 'SimHei',fontsize = 14)

    突出主副刻度
    使用 tick_params 对刻度线进行调整
    
    tick_params(which = , length = , labelsize = ,)
    
    
    
    tick_params(which='major',length=8,labelsize=10)
    
    
    tick_params(which='minor',length=4)

     调整 坐标轴 刻度 距离

    
    默认刻度 locator
    
    位置 MultipleLocator
    
    样式 FormatStrFormatter
    
    
    from matplotlib.ticker import MultipleLocator, FormatStrFormatter
    
    
    xmajorLocator   = MultipleLocator(1)
    ax.xaxis.set_major_locator(xmajorLocator)
    
    ymajorLocator   = MultipleLocator(1)
    ax.yaxis.set_major_locator(ymajorLocator)
    
    xminorLocator   = MultipleLocator(0.25)
    ax.xaxis.set_minor_locator(xminorLocator)
    
    yminorLocator   = MultipleLocator(0.25)
    ax.yaxis.set_minor_locator(yminorLocator)
    
    
    MultipleLocator(1) 表示刻度之间的间隔为 1
    如果觉得文章不错,可以分享给其他人哟~
  • 相关阅读:
    iview的modal点击确定消失(自动关闭)问题,自定义modal页脚
    vue实现组件数据双向绑定
    vue中封装svg-icon组件并使用
    闭包的概念
    vue基本集
    websocket
    99multiplication table
    h5c3增加了哪些新特性
    防抖与节流函数
    网页性能优化小技巧
  • 原文地址:https://www.cnblogs.com/hany-postq473111315/p/15202660.html
Copyright © 2011-2022 走看看