是否可以控制matplotlib标记的方向? [英] Is it possible to control matplotlib marker orientation?
问题描述
我想知道我是否有一个三角形标记,可以控制它的方向吗?我有一系列构面及其相应的顶点,我想绘制它们的底图.我知道使用Mayavi和tvtk.PolyData时它是直接脚本.但是由于我是在处理地图而不是3D对象,所以事情变得有些复杂.
I would like to know if I have a triangular marker, is it possible to control its orientation? I have a series of facets, with their corresponding vertices, and I would like to plot a basemap of them. I know it is straight forward script when using Mayavi and tvtk.PolyData. But since I'm dealing with maps and not 3D objects, things got a bit complicated.
ps:对于我正在使用底图工具的地图.
ps: for maps I'm using basemap tool.
感谢您的帮助.
推荐答案
您可以使用关键字参数创建自定义多边形 marker
,并向其传递3个数字(number of sides, style, rotation)
的元组.
You can create custom polygons using the keyword argument marker
and passing it a tuple of 3 numbers (number of sides, style, rotation)
.
要创建三角形,可以使用(3, 0, rotation)
,如下所示.
To create a triangle you would use (3, 0, rotation)
, an example is shown below.
import matplotlib.pyplot as plt
x = [1,2,3]
for i in x:
plt.plot(i, i, marker=(3, 0, i*90), markersize=20, linestyle='None')
plt.xlim([0,4])
plt.ylim([0,4])
plt.show()
这篇关于是否可以控制matplotlib标记的方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!