복붙노트

[PYTHON] Matplotlib Plot Dashed Circles (plt.scatter 대신 plt.plot 사용)

PYTHON

Matplotlib Plot Dashed Circles (plt.scatter 대신 plt.plot 사용)

다음을 감안할 때 :

import matplotlib.pyplot as plt 
import numpy as np 
#http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.scatter
x = np.random.randn(60) 
y = np.random.randn(60)
x2 = np.random.randn(60)
y2 = np.random.randn(60)

plt.plot(x, y, marker='o', markeredgecolor='r', linestyle='none', markerfacecolor='none')
plt.plot(x2, y2, marker='o', markeredgecolor='r', linestyle='none', markerfacecolor='none')
plt.show()

x2와 y2가 파선 (또는 심지어 점선으로 된) 원으로 그려지기를 바랍니다. 나머지 스크립트는 plt.plot과 함께 작동하기 때문에 plt.scatter의 사용을 피합니다. 여기 내가 찾고있는 것이 있습니다 :

미리 감사드립니다!

참고 : 내가 만든 실제 차트는 다음과 같습니다. 방금 다른 데이터 (미래 데이터)를 나타 내기 위해 육각형을 사용했습니다.

커스텀 범례와 팬더 데이터 프레임의 행 그룹에 플롯하면 plt.scatter로 극복 할 수 없었던 복잡한 레이어가 추가됩니다.

해결법

  1. ==============================

    1.mathtext 기능을 사용하여 STIX 글꼴의 점선 원 (ur '$ \ u25CC $')을 사용할 수 있습니다.

    mathtext 기능을 사용하여 STIX 글꼴의 점선 원 (ur '$ \ u25CC $')을 사용할 수 있습니다.

     plt.plot(x, y, marker=ur'$\u25CC$', markerfacecolor='r', 
                    markeredgecolor='r', markersize=30, linestyle='none', )
    

    markerfacecolor도 색상으로 설정됩니다.

    단점은 닫힌 원과 구별하기 위해 특정 크기가 필요하다는 것입니다.

  2. from https://stackoverflow.com/questions/41108055/matplotlib-plot-dashed-circles-using-plt-plot-instead-of-plt-scatter by cc-by-sa and MIT license