你能为我的情节中三角形的前导尖端着色吗?
Can you colour the leading tip of the triangles in my plot?
我正在绘制英国在特定位置的风速和风向。我想知道的是,有没有办法给三角形的前端着色,使风向更明显?
我的绘图代码是:
payload_user={'maddison.newman@example.com': {'lat': '51.45', 'lon': '-2.59'},'mandy.larson@example.com': {'lat': '52.06', 'lon': '-2.82'}}
m.plot(y=float(payload_user[email_user]['lat']),x=float(payload_user[email_user]['lon']),marker=(3,0,wind_direction_deg),color = col, markersize=7 )
plt.title("Wind speed and Direction in the UK for specific users")
plt.xlabel('Longitude')
plt.ylabel("Latitude")
带有风速和方向的英国地图:
我不知道有什么相当简单的方法可以使标记的一部分与标记的其余部分不同地着色。但是,为了显示方向,我可以想象使用非等边但等腰三角形是有意义的。
实现这种三角形的一种方法是使用 marker=verts
符号,其中 verts
是要用作标记的多边形的顶点。
import numpy as np
import matplotlib.pyplot as plt
def get_arrow(angle):
a = np.deg2rad(angle)
ar = np.array([[-.25,-.5],[.25,-.5],[0,.5],[-.25,-.5]]).T
rot = np.array([[np.cos(a),np.sin(a)],[-np.sin(a),np.cos(a)]])
return np.dot(rot,ar).T
for i, angle in enumerate([0,45,60,-36]):
plt.plot(i/10.,0.6,marker=get_arrow(angle), ms=30)
plt.show()
我正在绘制英国在特定位置的风速和风向。我想知道的是,有没有办法给三角形的前端着色,使风向更明显?
我的绘图代码是:
payload_user={'maddison.newman@example.com': {'lat': '51.45', 'lon': '-2.59'},'mandy.larson@example.com': {'lat': '52.06', 'lon': '-2.82'}}
m.plot(y=float(payload_user[email_user]['lat']),x=float(payload_user[email_user]['lon']),marker=(3,0,wind_direction_deg),color = col, markersize=7 )
plt.title("Wind speed and Direction in the UK for specific users")
plt.xlabel('Longitude')
plt.ylabel("Latitude")
带有风速和方向的英国地图:
我不知道有什么相当简单的方法可以使标记的一部分与标记的其余部分不同地着色。但是,为了显示方向,我可以想象使用非等边但等腰三角形是有意义的。
实现这种三角形的一种方法是使用 marker=verts
符号,其中 verts
是要用作标记的多边形的顶点。
import numpy as np
import matplotlib.pyplot as plt
def get_arrow(angle):
a = np.deg2rad(angle)
ar = np.array([[-.25,-.5],[.25,-.5],[0,.5],[-.25,-.5]]).T
rot = np.array([[np.cos(a),np.sin(a)],[-np.sin(a),np.cos(a)]])
return np.dot(rot,ar).T
for i, angle in enumerate([0,45,60,-36]):
plt.plot(i/10.,0.6,marker=get_arrow(angle), ms=30)
plt.show()