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 5 years have passed since last update.

PythonでMatplotlib例

4
Posted at

背景

よく忘れるので備忘録兼チートシート的な役割として

コード

# -*- 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()

image.png

おまけ

これはお遊び用

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()

image.png

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?