我在试着给画的线条加上一个轮廓错误栏(). 正如Can I give a border (outline) to a line in matplotlib plot function?\建议的那样,我尝试使用路径效果,但是我需要标记和行使用不同的路径效果。在
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patheffects as pe
x = np.arange(20)
y = x**1.3
# Two lines.
fig, ax = plt.subplots()
ax.errorbar(x, y, fmt='-o', lw=5, mew=3, ms=5, c='k')
ax.errorbar(x, y, fmt='-o', lw=2, mew=0, ms=5, c='r')
# Single line with path_effects.
y += 10
ax.errorbar(x, y, fmt='-o', lw=2, mew=0, ms=5, c='b',
path_effects=[pe.Stroke(linewidth=5, foreground='k'), pe.Normal()])
产生以下输出:
。在
这些方法的区别在于,前者的轮廓在线条和标记周围都显示为一个恒定的宽度,而在使用path_effects
的方法中,标记周围的轮廓更粗。有没有办法分别调整标记和线条的轮廓线宽?在
目前没有回答
相关问题 更多 >
编程相关推荐