天天看點

matplotlib - 極坐标上的散點圖

  • 極坐标上的散點圖
    matplotlib - 極坐标上的散點圖
  • 代碼
# -*- coding: utf-8 -*-

"""
Created on Fri Nov 16 20:07:14 2018
@author: LU
"""

import numpy as np
import matplotlib.pyplot as plt

np.random.seed(19680801)  # 随機數種子

N = 150
r = 2*np.random.rand(N)  # 2x,1行N列
theta = 2*np.pi*np.random.rand(N)  #2*pi*x
area = 200*r**2
colors = theta

fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')  #畫布分割為1行1列,圖像為從左到右從上到下數的第1塊
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
           
  • 參考

    o. https://matplotlib.org/gallery/pie_and_polar_charts/polar_scatter.html#sphx-glr-gallery-pie-and-polar-charts-polar-scatter-py

    o. https://blog.csdn.net/anneqiqi/article/details/64125186

繼續閱讀