在同一个IPython Notebook单元格中创建多个图表 [英] Make more than one chart in same IPython Notebook cell
问题描述
我已经启动了我的IPython笔记本
I have started my IPython Notebook with
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])
它仍然给你一个数字,但两个不同的地块彼此相邻。
It still gives you 1 figure, but with two different plots next to each other.
这篇关于在同一个IPython Notebook单元格中创建多个图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!