LoginSignup
0
1

More than 5 years have passed since last update.

「メモ用」正六角形の描画

Last updated at Posted at 2019-04-02

※matplotlibで正六角形を描画するコードです。

# https://python.atelierkobato.com/polygon/
# matplotlib.pyplotをインポート
import matplotlib.pyplot as plt

# matplotlib.patchesをインポート
import matplotlib.patches as pat

# Figureを作成
fig = plt.figure(figsize=(5, 5))

# FigureにAxes(サブプロット)を追加
ax = fig.add_subplot(111)

# 正六角形の描画
# 中心座標(0.5, 0.5), 半径0.4
# 塗り潰しはブルー、縁の色はブラック
cp = pat.CirclePolygon(xy = (0.5, 0.5), radius = 0.4,
resolution = 6, fc = "blue", ec = "black")

# Axesに正多角形を追加
ax.add_patch(cp)
0
1
2

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
0
1