【问题标题】:Can you colour the leading tip of the triangles in my plot?你能为我的情节中三角形的前导尖端着色吗?
【发布时间】:2018-05-31 05:03:07
【问题描述】:

我正在绘制英国特定位置的风速和风向。我想知道的是,有没有办法给三角形的尖端着色以使风向更明显?

我的绘制代码是:

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")

英国的风速和风向地图:

【问题讨论】:

    标签: python matplotlib plot colors symbols


    【解决方案1】:

    我不知道有任何相当简单的方法可以将标记的一部分与标记的其余部分不同地着色。然而,为了显示方向,我可以想象使用非等边但等腰三角形是有意义的。

    实现这种三角形的一种方法是使用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()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-06
      • 2022-01-26
      • 2020-07-17
      • 2014-10-25
      • 2021-11-17
      • 1970-01-01
      • 2017-01-02
      相关资源
      最近更新 更多