【发布时间】:2015-12-17 01:00:04
【问题描述】:
我正在使用 matplotlib/seaborn 绘制子图:
plt.figure()
s1 = plt.subplot(2, 1, 1)
# plot 1
# call seaborn here
s2 = plt.subplot(2, 1, 2)
# plot 2
plt.tight_layout()
plt.show()
我遇到了标记被轴隐藏的常见问题 (Add margin when plots run against the edge of the graph)。当我尝试调整边距时它不起作用:
s1 = plt.subplot(2, 1, 1)
s1.margins(0.05)
它没有给出错误,但也没有设置边距。
这是一个完整的例子:
gammas = sns.load_dataset("gammas")
s = plt.subplot(1, 1, 1)
# this does not change the x margins
s.get_axes().margins(x=0.05, y=0.01)
ax = sns.tsplot(time="timepoint", value="BOLD signal",
unit="subject", condition="ROI",
err_style="ci_bars",
interpolate=False,
data=gammas)
plt.show()
在上面,我试图使 x 边距更大,但 margins() 的 x 参数似乎没有效果。这是怎么做到的?
【问题讨论】:
-
我认为stackoverflow.com/questions/6230627/… 的答案比您链接的那个更好。对你起作用吗? (P.S. - 一个 complete 小型可运行示例会更令人愉快。)
-
@cphlewis:你说得对,我添加了一个完整的小例子
标签: python matplotlib seaborn