matplotlib 如何制作特殊标记
我想制作一个特殊的标记,这个标记在散点图命令中是没有的。我想要一个“图钉”形状的标记。原则上,箭头(用 fancyarrow 命令)是可以的,但它不允许我使用 vmin 和 vmax 选项,而这对我来说非常重要。让我来解释一下。
我有一组 x, y
坐标和速度。速度是通过颜色条来表示的。所以,当我读取 x, y
和速度,并使用 scatter 的 vmin 和 vmax 命令时,标记会自动用正确的颜色绘制。例如:
f.show_colorscale(cmap="gist_hsv",vmin=0,vmax=8e3)
f.scatter(x,y,c=vel,marker='o',s=50,vmin=0,vmax=8e3)
我只成功绘制了图钉的“头部”(就是一个填充的圆圈)。有没有什么想法可以让我在不同角度绘制图钉的“尾部”?
2 个回答
0
你可以看看 matplotlib.patches 这个模块。
In [23]: from matplotlib import patches
In [24]: patches.Arrow ?
Type: type
Base Class: <type 'type'>
String Form: <class 'matplotlib.patches.Arrow'>
Namespace: Interactive
File: c:\python26\lib\site-packages\matplotlib\patches.py
Docstring:
An arrow patch.
Constructor information:
Definition: patches.Arrow(self, x, y, dx, dy, width=1.0, **kwargs)
Docstring:
Draws an arrow, starting at (*x*, *y*), direction and length
given by (*dx*, *dy*) the width of the arrow is scaled by *width*.
Valid kwargs are:
agg_filter: unknown
alpha: float or None
.........................................
2
plot(x,y, "o", markersize=1)
就这么简单