背景
よく忘れるので備忘録兼チートシート的な役割として
コード
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
# 線描画
plt.plot([0.0 ,1.0], [0.0, 1.0])
# 点描画
plt.plot(2.0, 1.0, 'bo')
plt.scatter(3.0, 0.0)
# 棒描画
plt.bar(1.5, 1.5)
plt.fill_between([2.0, 3.0], [2.0, 3.0], [1.5, 1.5], alpha=0.8)
# 矢印描画
plt.quiver(0.0, 3.0, 1.0, -1.0)
plt.quiver(1.0, 2.0, 1.0, -1.0)
# タイトル、範囲
plt.title('Test Output')
plt.xlim(-1.0, 4.0)
plt.ylim(-0.5, 4.0)
plt.show()
おまけ
これはお遊び用
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = Axes3D(fig)
size = 256
# n = 15
n = 51
range_size = range(0, size, n)
for r in range_size:
for g in range_size:
for b in range_size:
color_word = '#' + format(r, '02x') + format(g, '02x') + format(b, '02x')
ax.scatter3D(r, g, b, c=color_word)
ax.set_xlabel('Red')
ax.set_ylabel('Green')
ax.set_zlabel('Blue')
plt.show()

