[英]How to rotate matplotlib fill-style-markers?
黑色是能夠旋轉的matplotlib 標記。 藍色/橙色是fill-style-markers ,我沒有設法以相同的方式旋轉它們。
這是生成圖形的代碼。 在此版本中不使用t
。
import matplotlib as mpl
import matplotlib.pyplot as plt
x = [0,10,20,30,40,50,60,70,80,90]
for i in x:
t = mpl.markers.MarkerStyle(marker='o')
t._transform = t.get_transform().rotate_deg(-i)
marker_style = dict(color='b', markerfacecoloralt='orange', markeredgecolor='w', markersize=25,
marker='o' )
plt.plot(i, i, marker=(2, 0, -i), c='k',markersize=30, linestyle='None')
plt.plot(i, i, marker=(3, 0, -i), c='k',markersize=10, linestyle='None')
plt.plot(i, i+20,fillstyle='top', **marker_style)
plt.margins(0.15); plt.grid();plt.show()
我試過沒有成功:
marker_style = dict(....., marker=(3, 3, -i) )
or
marker_style = dict(....., marker=t )
or
plt.plot(i, i+20,fillstyle='top', marker=(3, 3, -i)
謝謝你,如果你知道並告訴如何把這些東西放在一起! 使用plt.scatter()
解決方案也可以。
我不知道是否可以使用標記或 MarkerStyle 來完成,文檔只指定了如何填充除以一半的符號。 您可以通過將 2 個半圓放在一起並相應地旋轉它們來模仿這種行為。
import matplotlib.pyplot as plt
import matplotlib as mpl
plt.figure(1)
x = [0,10,20,30,40,50,60,70,80,90]
ax=plt.gca()
rot=0
for i in x:
HalfA=mpl.patches.Wedge((i, i+20), 5,theta1=0-rot,theta2=180-rot, color='r')
HalfB=mpl.patches.Wedge((i, i+20), 5,theta1=180-rot,theta2=360-rot, color='b')
rot=rot+360/len(x)
ax.add_artist(HalfA)
ax.add_artist(HalfB)
ax.plot(i, i, marker=(2, 0, -i), c='k',markersize=30, linestyle='None')
ax.plot(i, i, marker=(3, 0, -i), c='k',markersize=10, linestyle='None')
ax.set_xlim((-10, 110))
ax.set_ylim((-10, 130))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.