欢迎大神尝试
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.patches as mpatches
plt.subplots_adjust(left=0.00, bottom=0.0, right=1.00, top=0.95, wspace=0.0, hspace=0.00)
def hexagon_with_text(ax,x,y,text,size,**kwargs):
xy=np.array([x,y])
hexagon = mpatches.RegularPolygon(xy, 6, radius=size,facecolor='#5472bb',edgecolor='#3f597c', orientation=np.pi / 2)
ax.add_patch(hexagon)
ax.text(xy[0],xy[1],text,fontsize=size*14,color='white',va='center',ha='center')
def circle_with_text(ax,x,y,text,size,**kwargs):
xy=np.array([x,y])
circle = mpatches.Circle(xy, radius=size,facecolor='#83aa51',edgecolor='#546538')
ax.add_patch(circle)
ax.text(xy[0],xy[1],text,fontsize=size*14,color='white',va='center',ha='center')
def arrow(ax,x,y,size,**kwargs):
ax.plot(x,y,**kwargs)
theta=np.arctan2(x[1]-x[0],y[1]-y[0])
xy=np.array([x[1]-size*np.sin(theta),y[1]-size*np.cos(theta)])
triangle = mpatches.RegularPolygon(xy, 3, radius=size,color=kwargs['color'], orientation=-theta)
ax.add_patch(triangle)
def arrow_with_rad(ax,x,y,radius,size,**kwargs):
d=np.sqrt((x[1]-x[0])**2+(y[1]-y[0])**2)
theta=np.arctan2(x[1]-x[0],y[0]-y[1])
x0=(x[0]+x[1])/2+np.cos(theta)*np.sqrt(radius**2-(d/2)**2)
y0=(y[0]+y[1])/2+np.sin(theta)*np.sqrt(radius**2-(d/2)**2)
theta1=np.arctan2(y[0]-y0,x[0]-x0)
theta2=np.arctan2(y[1]-y0,x[1]-x0)
arc_x = []
arc_y = []
for theta in np.arange(theta1,theta2+(np.pi*2),np.pi/180):
temp_x=x0 + radius * np.cos(theta)
temp_y=y0 + radius * np.sin(theta)
if((temp_x-x[0])**2+(temp_y-y[0])**2>1 and (temp_x-x[1])**2+(temp_y-y[1])**2>1):
arc_x.append(temp_x)
arc_y.append(temp_y)
ax.plot(arc_x,arc_y,**kwargs)
theta=np.arctan2(arc_y[-2]-arc_y[-1],arc_x[-