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

  • 相关阅读:
    XMPP协议之消息回执解决方案
    使用js在网页上记录鼠标划圈的小程序
    数据库SQL,NoSQL之小感悟
    MongoDB安装与使用体验
    缓存遇到的数据过滤与分页问题
    Tomcat shutdown执行后无法退出进程问题排查及解决
    Apache Ignite之集群应用测试
    Ignite性能测试以及对redis的对比
    学习AOP之深入一点Spring Aop
    学习AOP之认识一下Spring AOP
  • 原文地址:https://www.cnblogs.com/black-mamba/p/9076565.html
Copyright © 2011-2022 走看看