zoukankan      html  css  js  c++  java
  • matplotlib之设置极坐标起点的位置

     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 plt.subplots_adjust(wspace=0.3)#控制两个subplot的间距,否则会有部分标签重叠
    16 ax1 = plt.subplot(121, polar=True)
    17 ax2 = plt.subplot(122, polar=True)
    18 
    19 #ax2.set_theta_zero_location("N")   #将起点位置设为 北部
    20 ax2.set_theta_zero_location("N", 30.0)#将起点位置设为 北部 偏移30度的位置,偏移的方向总是逆时针方向,无论theta direction的顺时针或逆时针。
    21 
    22 plt.figtext(0.52, 0.95, '设置极坐标(ρ, 0)的位置', ha='center', size=20,fontproperties=zhfont)#设置figure的标题
    23 plt.savefig('0_degrees.jpg')
    24 plt.show()

    set_theta_zero_location(loc, offset=0.0)
      Sets the location of theta’s zero. (Calls set_theta_offset with the correct value in radians under the hood.)

    loc : str
      May be one of “N”, “NW”, “W”, “SW”, “S”, “SE”, “E”, or “NE”.
    offset : float, optional
      An offset in degrees to apply from the specified loc. Note: this offset is always applied counter-clockwise regardless of the direction setting.

    reference: https://matplotlib.org/api/projections_api.html?highlight=set_theta_zero_location#matplotlib.projections.polar.PolarAxes.set_theta_zero_location

  • 相关阅读:
    作为另一个函数的值(读书摘)
    算法-二分查找与二叉排序树
    算法-图
    算法-二叉树
    算法-分治
    算法-回溯
    算法-动态规划
    算法-贪心
    算法-堆
    算法-栈,队列
  • 原文地址:https://www.cnblogs.com/black-mamba/p/9076388.html
Copyright © 2011-2022 走看看