4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Python]Matplotlibによる極座標表示の散布図

Posted at

極座標表示の散布図

add_subplotの引数にprojection='polar'を指定することで極座標にできる。

import numpy as np
import matplotlib.pyplot as plt

N = 100
r = np.random.rand(N)
theta = 2 * np.pi * np.random.rand(N)

fig = plt.figure(figsize=(8,8))
ax = fig.add_subplot(111, projection='polar')
ax.scatter(theta, r)
ax.set_title('Polar coordinates',fontsize=18)

image.png

点の大きさ

import numpy as np
import matplotlib.pyplot as plt

N = 100
r = np.random.rand(N)
theta = 2 * np.pi * np.random.rand(N)

fig = plt.figure(figsize=(8,8))
ax = fig.add_subplot(111, projection='polar')
ax.scatter(theta, r, s=100)
ax.set_title('Polar coordinates',fontsize=18)

image.png

角度の範囲指定

import numpy as np
import matplotlib.pyplot as plt

N = 100
r = np.random.rand(N)
theta = 2 * np.pi * np.random.rand(N)


fig = plt.figure(figsize=(8,8))
ax = fig.add_subplot(111, projection='polar')
ax.scatter(theta, r)
ax.set_title('Polar coordinates',fontsize=18)
ax.set_thetamin(0)
ax.set_thetamax(180)

image.png

r方向の範囲指定

import numpy as np
import matplotlib.pyplot as plt

N = 100
r = np.random.rand(N)
theta = 2 * np.pi * np.random.rand(N)

fig = plt.figure(figsize=(8,8))
ax = fig.add_subplot(111, projection='polar')
ax.scatter(theta, r)
ax.set_title('Polar coordinates',fontsize=18)
ax.set_rmin(0)
ax.set_rmax(0.5)

image.png

参考URL https://matplotlib.org/3.3.1/gallery/pie_and_polar_charts/polar_scatter.html

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?