python 2.7 - Plotting circle diagram with rotary arrow -


this diagram clipped paper.

http://i11.tietuku.com/e1c71d1b84b37a51.png

i can plot circle , straight arrow, how plot rotary arrow in specific angle?

you can draw circle , rotary arrow in matplotlib using sine/cosine, arc , arrow:

import math matplotlib.patches import arc import matplotlib.pyplot plt  ax = plt.axes() x0, y0 = 0.5, 0.5 radius = 0.4 angle = 135 angle_rad = angle * math.pi / 180  # degrees radians # draw circle circle = plt.circle((x0,y0), radius, color='red', fill=false) fig = plt.gcf() fig.gca().add_artist(circle) # draw radius arrow head_length = 0.05 ax.arrow(x0, y0,          (radius - head_length) * math.cos(angle_rad),          (radius - head_length) * math.sin(angle_rad),          head_width=0.05, head_length=head_length, fc='k', ec='k') # draw arc arrow. arc_radius = radius / 4 arc = arc((x0, y0),           arc_radius*2, arc_radius*2,  # ellipse width , height           theta1=0, theta2=angle, linestyle='dashed') ax.add_patch(arc) arc_arrow_length = 0.03 arc_arrow_dx = arc_arrow_length * math.cos(angle_rad + math.pi / 2) arc_arrow_dy = arc_arrow_length * math.sin(angle_rad + math.pi / 2) ax.arrow(     x0 + arc_radius * math.cos(angle_rad) - arc_arrow_dx,     y0 + arc_radius * math.sin(angle_rad) - arc_arrow_dy,     # want define vector,     # don't want draw line besides arrow head,     # make arrow "body" unnoticeable.     arc_arrow_dx * 0.000001,     arc_arrow_dy * 0.000001,     head_width=0.01,     head_length=0.03,     color='black') plt.show() 

result

please note solution not cleanest, there better way draw arc , arrow @ once.

you may want try fancyarrowpatch draw nice arrow.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -