【问题标题】:how to specify edge colors with triplot如何用 triplot 指定边缘颜色
【发布时间】:2019-10-30 08:03:13
【问题描述】:

在以下使用 matplotlib.triplot 的示例中,如何指定边缘颜色以具有颜色,例如 0xFFAC67?

import matplotlib.pyplot as plt
import matplotlib.tri as tri
import numpy as np
xy = np.asarray([ [0.2, 0.1], [0.9, -0.1], [1.2, 1.29] ])
x = np.degrees(xy[:, 0])
y = np.degrees(xy[:, 1])
triangles = np.asarray([ [0, 1,  2] ])
mesh = tri.Triangulation( x, y, triangles )
plt.figure()
plt.gca().set_aspect('equal')
plt.triplot( mesh, 'g-', lw=1.0 )
plt.show()

【问题讨论】:

    标签: matplotlib triplot


    【解决方案1】:

    您可以使用参数c 指定颜色。您指定的颜色无效,但将0x 替换为# 的工作原理如下

    plt.gca().set_aspect('equal')
    plt.triplot(mesh, '-', lw=1.0, c='#FFAC67')
    plt.show()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-08
      • 2015-04-06
      相关资源
      最近更新 更多