본문 바로가기
Matplotlib/산점도(scatter)

[파이썬 matplotlib] 산점도 마커 종류 설정

by 만다린망고 2020. 11. 17.
반응형

[파이썬 matplotlib] 

산점도 마커 종류 설정



산점도의 마커 스타일은 marker 옵션을 사용하여 입력합니다. 다양한 종류의 마커가 있습니다. 마커는 크게 'filled marker' 와 'unfilled marker' 로 나뉩니다. 


둘의 차이는 내부에 채워진 색을 변경할 수 있는가 여부입니다.


marker들은 matplotlib.lines 의 Line2D 클래스 안에 들어있습니다. 




1) unfilled marker


unfilled marker의 종류를 확인해봅시다. 


>>> from matplotlib.lines import Line2D

>>> Line2D.markers.items()

dict_items([('.', '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'), ('P', 'plus_filled'), ('X', 'x_filled'), (0, 'tickleft'), (1, 'tickright'), (2, 'tickup'), (3, 'tickdown'), (4, 'caretleft'), (5, 'caretright'), (6, 'caretup'), (7, 'caretdown'), (8, 'caretleftbase'), (9, 'caretrightbase'), (10, 'caretupbase'), (11, 'caretdownbase'), ('None', 'nothing'), (None, 'nothing'), (' ', 'nothing'), ('', 'nothing')])




2) filled marker


filled marker 의 종류를 확인해봅시다.


>>> Line2D.filled_markers

('o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd', 'P', 'X')




예시


import matplotlib.pyplot as plt

import numpy as np


X=np.random.randn(100)

Y=np.random.randn(100)


plt.scatter(X,Y,marker='s')


plt.show()


반응형

댓글