zoukankan      html  css  js  c++  java
  • matplotlib之极坐标系的极角网格线(thetagrids)的显示刻度

    极坐标系的极角网格线(thetagrids)的显示刻度

     1 #!/usr/bin/env python3
     2 #-*- coding:utf-8 -*-
     3 ############################
     4 #File Name: polar.py
     5 #Author: frank
     6 #Mail: frank0903@aliyun.com
     7 #Created Time:2018-05-22 22:08:01
     8 ############################
     9 import matplotlib.pyplot as plt
    10 import numpy as np
    11 import matplotlib as mpl
    12 
    13 zhfont = mpl.font_manager.FontProperties(fname='/usr/share/fonts/truetype/wqy/wqy-microhei.ttc')
    14 
    15 ax = plt.subplot(111, polar=True)
    16 
    17 plt.figtext(0.52, 0.95, '默认labels为角度(degree)', ha='center', size=20,fontproperties=zhfont)
    18 plt.thetagrids(np.linspace(0, 360, 6, endpoint=False))
    19 plt.savefig('default_degrees.jpg')
    20 
    21 plt.figtext(0.52, 0.95, '指定labels', ha='center', size=20,fontproperties=zhfont)
    22 plt.thetagrids(np.linspace(0, 360, 6, endpoint=False), ['a', 'b', 'c', 'd', 'e', 'f'])
    23 plt.savefig('special_degrees.jpg')
    24 
    25 
    26 plt.show()

    matplotlib.pyplot.thetagrids(*args, **kwargs)
      Get or set the theta locations of the gridlines in a polar plot.

      get or set 极角轴显示刻度。

    If no arguments are passed, return a tuple (lines, labels) where lines is an array of radial gridlines (Line2D instances) and labels is an array of tick labels (Text instances):
      lines, labels = thetagrids()
    Otherwise the syntax is:
      lines, labels = thetagrids(angles, labels=None, fmt='%d', frac = 1.1)
      set the angles at which to place the theta grids (these gridlines are equal along the theta dimension).

    angles is in degrees. 

    angles 是角度值,不能是弧度值


    labels, if not None, is a len(angles) list of strings of the labels to use at each angle. 

    If labels is None, the labels will be fmt%angle.

    如果labels不为空,那么极角网格线的显示刻度为labels。

    如果labels为空,那么极角网格线的显示刻度为 角度值。


    frac is the fraction of the polar axes radius at which to place the label (1 is the edge). e.g., 1.05 is outside the axes and 0.95 is inside the axes.

    frac 设置 极角显示刻度 距离 极角轴的距离。例如,极径为1,frac=1.1,那么极角的刻度显示的位置 离 r=1的极角网格线 0.1长度。

    Return value is a list of tuples (lines, labels):
      lines are Line2D instances
      labels are Text instances.

    Note that on input, the labels argument is a list of strings, and on output it is a list of Text instances.

    reference: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.thetagrids.html?highlight=thetagrids#matplotlib.pyplot.thetagrids

  • 相关阅读:
    合并2个dll成一个,好处你懂的
    来吧,给你的Winform列表控件画个妆
    DataGridView 的cell赋值没有线程间访问的限制吗?
    设计模式之单例模式
    一个铜钱的故事(转)
    博客美化小结
    FTP操作类(支持异步)
    多线程学习之AsyncOperation实现线程间交互
    消息传递选择:返回值 or 抛出异常
    IIS8.5关于“ 配置错误 不能在此路径中使用此配置节”的解决办法
  • 原文地址:https://www.cnblogs.com/black-mamba/p/9076565.html
Copyright © 2011-2022 走看看