2013-11-24 24 views
0

我有很多的返回數據的功能,如如何插入圖形進入一個新的次要情節在matplotlib

def create_predef_plot(): 
    f, ax = plt.subplots() 
    ax.plot(randn(10)) 
    return f, ax 

我如何可以插入通過create_predef_plot返回到F2

plot1 = create_predef_plot() 
f2, (ax21, ax22) = subplots(1,2) 
+0

http://stackoverflow.com/questions/18284296/matplotlib-using-a-figure-object-to-initialize-a-plot/18302072#18302072可能感興趣 – tacaswell

回答

1

情節1)這與IPython無關,它是純matplotlib

2)常見模式是使用ax關鍵字參數。

def create_predef_plot(ax=None): 
    if not ax 
     f, ax = plt.subplots() 
    ax.plot(randn(10)) 
    return ax 


f2, (ax21, ax22) = subplots(1,2) 
create_predef_plot(ax=ax22)