Ale*_*lex 12 python plot matplotlib
我尝试:
points = [...]
axe.plot([i[0] for i in points], [i[1] for i in points], linestyle='-', linewidth=10,
color='black', markeredgewidth=2, markeredgecolor='green')
Run Code Online (Sandbox Code Playgroud)
但我只是得到一个黑色轮廓.我怎样才能实现下图所示的内容?

Mat*_*ijn 35
如果您绘制两次线,它将不会显示在图例中.使用patheffects确实更好.这是两个简单的例子:
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.patheffects as pe
# setup data
x = np.arange(0.0, 1.0, 0.01)
y = np.sin(2*2*np.pi*t)
# create line plot including an outline (stroke) using path_effects
plt.plot(x, y, color='k', lw=2, path_effects=[pe.Stroke(linewidth=5, foreground='g'), pe.Normal()])
# custom plot settings
plt.grid(True)
plt.ylim((-2, 2))
plt.legend(['sine'])
plt.show()
Run Code Online (Sandbox Code Playgroud)
或者,如果要添加线条阴影
# create line plot including an simple line shadow using path_effects
plt.plot(x, y, color='k', lw=2, path_effects=[pe.SimpleLineShadow(shadow_color='g'), pe.Normal()])
# custom plot settings
plt.grid(True)
plt.ylim((-2, 2))
plt.legend(['sine'])
plt.show()
Run Code Online (Sandbox Code Playgroud)
aga*_*rs3 10
只需将线条绘制两次,厚度不同:
axe.plot([i[0] for i in points], [i[1] for i in points], linestyle='-', linewidth=10,
color='green')
axe.plot([i[0] for i in points], [i[1] for i in points], linestyle='-', linewidth=5,
color='black')
Run Code Online (Sandbox Code Playgroud)
更一般的答案是使用路径效应。为任何使用路径渲染的艺术家提供简单的轮廓和阴影(以及其他东西)。
matplotlib 文档(和示例)非常容易访问。
http://matplotlib.org/users/patheffects_guide.html
http://matplotlib.org/examples/pylab_examples/patheffect_demo.html
| 归档时间: |
|
| 查看次数: |
9776 次 |
| 最近记录: |