在同一个 IPython Notebook 单元格中制作多个图表 [英] Make more than one chart in same IPython Notebook cell
问题描述
我已经用
ipython notebook --pylab inline
这是我在一个单元格中的代码
This is my code in one cell
df['korisnika'].plot()
df['osiguranika'].plot()
这工作正常,它会画两条线,但在同一个图表上.
This is working fine, it will draw two lines, but on the same chart.
我想在单独的图表上绘制每条线.如果图表彼此相邻,而不是一个接一个,那就太好了.
I would like to draw each line on a separate chart. And it would be great if the charts would be next to each other, not one after the other.
我知道我可以将第二行放在下一个单元格中,然后我会得到两个图表.但我希望图表彼此靠近,因为它们代表相同的逻辑单元.
I know that I can put the second line in the next cell, and then I would get two charts. But I would like the charts close to each other, because they represent the same logical unit.
推荐答案
先制作多个轴,然后传递给 Pandas 绘图函数,如:
Make the multiple axes first and pass them to the Pandas plot function, like:
fig, axs = plt.subplots(1,2)
df['korisnika'].plot(ax=axs[0])
df['osiguranika'].plot(ax=axs[1])
它仍然给你 1 个图形,但有两个彼此相邻的不同图.
It still gives you 1 figure, but with two different plots next to each other.
这篇关于在同一个 IPython Notebook 单元格中制作多个图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!