【发布时间】:2013-11-19 13:36:53
【问题描述】:
在 IPython Notebook 中使用 Matplotlib,我想创建一个带有从函数返回的子图的图形:
import matplotlib.pyplot as plt
%matplotlib inline
def create_subplot(data):
more_data = do_something_on_data()
bp = plt.boxplot(more_data)
# return boxplot?
return bp
# make figure with subplots
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize=(10,5))
ax1 -> how can I get the plot from create_subplot() and put it on ax1?
ax1 -> how can I get the plot from create_subplot() and put it on ax2?
我知道我可以直接将绘图添加到轴上:
ax1.boxplot(data)
但是我怎样才能从函数中返回一个图并将其用作子图呢?
【问题讨论】:
标签: python matplotlib ipython