matplotlib로 만든 마커에서 여러 색상을 사용하고 싶습니다. 두 가지 색상을 사용하는 것이 어려웠습니다 (this example). this documentation의 몇 가지 추가 정보가 있습니다. 그러나 2 가지 색상 이상의 마커를 만들 수 있는지 궁금합니다. 나는 하나의 마커가 실제로 3 가지 다른 색을 얻길 원하는 상황에 처해있다. (맵상의 한 점은 세 가지 다른 관찰을 가리킨다.)matplotlib 마커에서 여러 색상 채우기
0
A
답변
1
당신은 여기에 표시된하기 matplotlib 예에 따라이 작업을 수행 할 수 있습니다
matplotlib.org/examples/api/scatter_piecharts.html
나는 약간 ax.plot
대신 ax.scatter
사용하는 예제를 변경 한 아래.
는 기본적으로이 모든 마커, 대신 scatter
의 s
kwarg를 사용하여 크기가 동일해야 함을 의미합니다, 당신은 plot
의 ms
(또는 markersize
) kwarg 사용합니다.
또한 facecolor
대신 markerfacecolor
을 정의해야합니다.
그 밖의 모든 변경 사항은 원래 예제와 동일하게 유지됩니다.
"""
This example makes custom 'pie charts' as the markers for a scatter plot
Thanks to Manuel Metz for the example
"""
import math
import numpy as np
import matplotlib.pyplot as plt
# first define the ratios
r1 = 0.2 # 20%
r2 = r1 + 0.4 # 40%
# define some sizes of the plot marker
markersize = 20 # I changed this line
# calculate the points of the first pie marker
#
# these are just the origin (0,0) +
# some points on a circle cos,sin
x = [0] + np.cos(np.linspace(0, 2*math.pi*r1, 10)).tolist()
y = [0] + np.sin(np.linspace(0, 2*math.pi*r1, 10)).tolist()
xy1 = list(zip(x, y))
s1 = max(max(x), max(y))
# ...
x = [0] + np.cos(np.linspace(2*math.pi*r1, 2*math.pi*r2, 10)).tolist()
y = [0] + np.sin(np.linspace(2*math.pi*r1, 2*math.pi*r2, 10)).tolist()
xy2 = list(zip(x, y))
s2 = max(max(x), max(y))
x = [0] + np.cos(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
y = [0] + np.sin(np.linspace(2*math.pi*r2, 2*math.pi, 10)).tolist()
xy3 = list(zip(x, y))
s3 = max(max(x), max(y))
fig, ax = plt.subplots()
# Here's where I made changes
ax.plot(np.arange(3), np.arange(3), marker=(xy1, 0),
ms=markersize, markerfacecolor='blue') # I changed this line
ax.plot(np.arange(3), np.arange(3), marker=(xy2, 0),
ms=markersize, markerfacecolor='green') # I changed this line
ax.plot(np.arange(3), np.arange(3), marker=(xy3, 0),
ms=markersize, markerfacecolor='red') # I changed this line
plt.margins(0.05)
plt.show()
관련 문제
- 1. Matplotlib 여러 줄 사이에 채우기
- 2. matplotlib 플롯에서 여러 색상 사용
- 3. 여러 범례 및 여러 색상/모양 matplotlib
- 4. Matplotlib - 채우기 문제
- 5. Matplotlib 색상 표
- 6. matplotlib 등고선도에서 색상 선택
- 7. Matplotlib 세트 색상
- 8. Python Matplotlib 히스토그램 색상
- 9. 색상 코드 matplotlib 마커
- 10. 하기 matplotlib 색상 레이블
- 11. matplotlib 패치의 색상 그라디언트?
- 12. 그라디언트로 색상 배열 채우기
- 13. 여러 마커에서 Google지도 카메라 위치
- 14. 색상 막대의 색상 범위 설정 Matplotlib
- 15. matplotlib 색상 표에 중복 값을주는 색상 표
- 16. matplotlib 색상 맵에서 시작 색상 선택
- 17. matplotlib 이산 점 사이에 채우기
- 18. Python Matplotlib : plot_date의 색상 변경
- 19. matplotlib-Basmap에 색상 벡터 전달하기
- 20. matplotlib imshow - 기본 색상 정규화
- 21. 하기 matplotlib : 색상 분리 범례
- 22. matplotlib hexbin의 0 값 색상
- 23. matplotlib plot_surface 명령의 색상 막대
- 24. 파이썬 matplotlib/basemap의 색상 상태
- 25. Matplotlib - 개별 화살표의 색상 구분
- 26. matplotlib 색상 막대 범위 설정
- 27. matplotlib 바이올린 플롯의 색상 변경
- 28. 막대 그래프가있는 Matplotlib 색상 막대
- 29. Matplotlib imshow - 다른 색상 표시
- 30. 하기 matplotlib 절반 색상 축
http://matplotlib.org/examples/api/scatter_piecharts.html – tom
@ 톰도 정상 플롯 (plt.plot (..))와 함께 작동하는 것이 무엇입니까? –
@tom 또는 다른 마커 –