Как повернуть маркеры заполнения-стиля matplotlib? - PullRequest
0 голосов
/ 18 января 2019

enter image description here

Черным цветом обозначены маркеры matplotlib , которые могут вращаться . В синем / оранжевом * маркеры стиля заполнения , и мне не удалось повернуть их таким же образом.

Вот код, сгенерировавший графику. В этой версии 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() тоже подойдет.

1 Ответ

0 голосов
/ 19 января 2019

Я не знаю, можно ли это сделать с помощью маркеров или 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))

This is the output that I get

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...