相关疑难解决方法(0)

Matplotlib自定义标记/符号

所以有这个指南:http: //matplotlib.org/examples/pylab_examples/scatter_symbol.html 在此输入图像描述

# http://matplotlib.org/examples/pylab_examples/scatter_symbol.html
from matplotlib import pyplot as plt
import numpy as np
import matplotlib

x = np.arange(0.0, 50.0, 2.0)
y = x ** 1.3 + np.random.rand(*x.shape) * 30.0
s = np.random.rand(*x.shape) * 800 + 500

plt.scatter(x, y, s, c="g", alpha=0.5, marker=r'$\clubsuit$',
            label="Luck")
plt.xlabel("Leprechauns")
plt.ylabel("Gold")
plt.legend(loc=2)
plt.show()
Run Code Online (Sandbox Code Playgroud)

但是,如果你像我一样,不想使用会标记......

你如何制作自己的标记_________?

UPDATE

我喜欢这种特殊的标记类型,它很容易使用简单的matplotlib语法进行调整:

from matplotlib import pyplot as plt
import numpy as np
import matplotlib

x = np.arange(0.0, 50.0, 2.0)
y = x ** 1.3 + np.random.rand(*x.shape) * 30.0 …
Run Code Online (Sandbox Code Playgroud)

python matplotlib

28
推荐指数
2
解决办法
2万
查看次数

如何使用自定义标记与情节?

我想在散点图和折线图中使用客户标记.如何从PNG文件中制作自定义标记?

matplotlib

15
推荐指数
3
解决办法
1万
查看次数

如何更改matplotlib注释中的箭头样式?

我想更改注释 ( ) 中的箭头头matplotlib,但与其他属性(例如 )一起使用时不起作用shrink。通过查看参数集,它似乎改变了创建的对象的类型。


例子

以下代码显示了两种类型的注释箭头。

import matplotlib.pyplot as plt

import numpy as np

xx = np.linspace(0,8)
yy = np.sin(xx)
fig, ax = plt.subplots(1,1, figsize=(8,5))
ax.plot(xx,yy)
ax.set_ylim([-2,2])

ax.annotate( 'local\nmax', xy=(np.pi/2, 1), xytext=(1,1.5), ha='center', \
            arrowprops={'shrink':0.05})
ax.annotate( 'local\nmin', xy=(np.pi*3/2, -1), xytext=(5,0), ha='center', \
            arrowprops={'arrowstyle':'->'})
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


问题

我尝试将箭头类型与第一个注释中的其他属性一起设置,如下所示:

ax.annotate( 'other\nmax', xy=(np.pi*5/2, 1), xytext=(7,1.5), ha='center', \
            arrowprops={'arrowstyle':'->', 'shrink':0.05}) 
Run Code Online (Sandbox Code Playgroud)

但是,该行会引发错误:

AttributeError: Unknown property shrink
Run Code Online (Sandbox Code Playgroud)

为什么它不起作用?

如何更改注释的箭头样式?

相关问题


我在用:

蟒蛇:3.4.3 + numpy:1.11.0 + matplotlib:1.5.1

python numpy matplotlib

5
推荐指数
1
解决办法
5445
查看次数

标签 统计

matplotlib ×3

python ×2

numpy ×1