matplotlib之極座標系的極角網格線(thetagrids)的顯示刻度

極座標系的極角網格線(thetagrids)的顯示刻度html

 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.python

  get or set 極角軸顯示刻度。api

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).ide

angles is in degrees. spa

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


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

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

若是labels不爲空,那麼極角網格線的顯示刻度爲labels。utf-8

若是labels爲空,那麼極角網格線的顯示刻度爲 角度值。ci


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

相關文章
相關標籤/搜索