반응형
MatPlotLib : 동일한 산점도의 여러 데이터 세트
동일한 산점도에 여러 데이터 세트를 플로팅하고 싶습니다.
cases = scatter(x[:4], y[:4], s=10, c='b', marker="s")
controls = scatter(x[4:], y[4:], s=10, c='r', marker="o")
show()
위는 가장 최근의 scatter()
나는 또한 시도했다 :
plt = subplot(111)
plt.scatter(x[:4], y[:4], s=10, c='b', marker="s")
plt.scatter(x[4:], y[4:], s=10, c='r', marker="o")
show()
Axes
동일한 서브 플롯에 계속 그리 려면 객체에 대한 참조가 필요합니다 .
import matplotlib.pyplot as plt
x = range(100)
y = range(100,200)
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.scatter(x[:4], y[:4], s=10, c='b', marker="s", label='first')
ax1.scatter(x[40:],y[40:], s=10, c='r', marker="o", label='second')
plt.legend(loc='upper left');
plt.show()
나는 똑같은 문제가 있었기 때문에이 질문을 보았습니다. 받아 들여지는 대답은 잘 작동하지만 matplotlib 버전 2.1.0
에서는 참조를 사용하지 않고 한 플롯에 두 개의 산점도를 갖는 것이 매우 간단합니다.Axes
import matplotlib.pyplot as plt
plt.scatter(x,y, c='b', marker='x', label='1')
plt.scatter(x, y, c='r', marker='s', label='-1')
plt.legend(loc='upper left')
plt.show()
모르겠습니다. 잘 작동합니다. 정확한 명령 :
import scipy, pylab
ax = pylab.subplot(111)
ax.scatter(scipy.randn(100), scipy.randn(100), c='b')
ax.scatter(scipy.randn(100), scipy.randn(100), c='r')
ax.figure.show()
여기에 설명 된대로 데이터가 Dataframe에 표시되는 경우 Pandas에서도이 작업을 쉽게 수행 할 수 있습니다.
http://pandas.pydata.org/pandas-docs/version/0.15.0/visualization.html#scatter-plot
참고 URL : https://stackoverflow.com/questions/4270301/matplotlib-multiple-datasets-on-the-same-scatter-plot
반응형
'IT TIP' 카테고리의 다른 글
전역 및 정적 변수가 기본값으로 초기화되는 이유는 무엇입니까? (0) | 2020.11.30 |
---|---|
Android WebView는 스크롤바를위한 공간을 남깁니다. (0) | 2020.11.30 |
크롬 확장 프로그램 용 자바 스크립트를 사용하여 스크린 샷 찍기 (0) | 2020.11.30 |
Rails가 Ajax 게시물에서 세션을 다시로드하지 않음 (0) | 2020.11.30 |
CSS에서 100 %의 1/3을 표현하는 가장 좋은 방법은 무엇입니까? (0) | 2020.11.30 |