python - How to plot 2 subplots from different functions in the same window(figure)? -
for specific reasons have 2 functions, each of them creates plot in 2 different windows. possible unify 2 plots in 1 window, without unifying functions? thanks!
edit: have 2 involved functions , database: function 1 in file1.py plots 2d-line plot:
plt.figure("test12") ax=plt.subplot(111) ax.plot(array[:,10])
in file2.py theres other function, plots filled contour:
plt.figure("test13") ax = plt.subplot(111) ax.contourf(x,y,data) plt.gca().set_aspect('equal')
if use plt.show
as usual, result 2 different windows.
re-factor function take axes
object draw argument:
def fun1(ax): ax.plot(range(5)) def fun2(ax): ax.plot(range(5)[::-1]) fig, ax = plt.subplots(1, 1) fun1(ax) fun2(ax) plt.draw()
Comments
Post a Comment