Pythonのデータビジュアライゼーションライブラリ、matplotlibでは、散布図や折れ線グラフなどのプロットに使用するマーカーの形をカスタマイズすることができます。
以下に、matplotlibで使用可能なマーカーの一部を紹介します。
markers = {
".": "point",
",": "pixel",
"o": "circle",
"v": "triangle_down",
"^": "triangle_up",
"<": "triangle_left",
">": "triangle_right",
"1": "tri_down",
"2": "tri_up",
"3": "tri_left",
"4": "tri_right",
"8": "octagon",
"s": "square",
"p": "pentagon",
"*": "star",
"h": "hexagon1",
"H": "hexagon2",
"+": "plus",
"x": "x",
"D": "diamond",
"d": "thin_diamond",
"|": "vline",
"_": "hline",
"None": "nothing",
None: "nothing",
" ": "nothing",
"": "nothing"
}
これらのマーカーは、plot
やscatter
メソッドのmarker
引数として指定することで使用できます。
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(10)
y = np.random.rand(10)
for marker in markers.keys():
plt.plot(x, y, marker=marker)
plt.show()
このように、matplotlibを使えば、データの特性に合わせてマーカーの形を自由に選択し、視覚的にわかりやすいグラフを作成することができます。.