【发布时间】:2023-03-13 21:24:02
【问题描述】:
如何在 JupyterLab 的同一个 Jupyter 笔记本单元格中的多个图形之间添加空格? 为清楚起见,我不是要在子图之间添加空间,而是在图形之间添加空间。
例如,
import matplotlib.pyplot as plt
fig1 = plt.figure()
_ = plt.plot(x,y)
fig2 = plt.figure()
_ = plt.hist(z)
将“附加”两个数字,我想在它们之间添加空格,类似于 print('\n') 在打印输出之间添加空格的方式。
为了进一步澄清,使用:
import matplotlib.pyplot as plt
fig1 = plt.figure()
_ = plt.plot([1, 2], [2, 3])
print('\n' * 4)
fig2 = plt.figure()
_ = plt.hist([1, 2, 3])
在 JupyterLab 中导致新线被放置在图的前面,而不是在它们之间:
【问题讨论】:
-
只需
print('\n')应该再次成功。 -
@ddg,我已经试过了。它没有。
-
尝试添加
plt.tight_layout()matplotlib.org/3.3.3/tutorials/intermediate/… -
@rzaratx,这将有助于子图。我的目标是在单个数字之间添加空间
-
嗯,它在我的 Jupyter 中工作
标签: python python-3.x matplotlib jupyter-lab