from matplotlib.pylab import *
fig = plt.figure(1) 
fig.clf() 
data = np.random.random((3,3)) 
xaxis = np.arange(0,3) 
yaxis = np.arange(0,3) 
ax1 = fig.add_subplot(211) 
im = ax1.imshow(data, interpolation='none') 
c = ax1.contour(xaxis, yaxis, data, colors='k') 
#----------------
# draw ax1 first, so you can get proper position of ax1
fig.canvas.draw() 
point_bl, point_tr = ax1.get_position().get_points()  # ax1's bottom-left
and top-right
ax2 = fig.add_subplot(212)
space = 0.45  # space between ax2's bottom left and ax1's bottom left in
percentage
ax2.set_position([point_bl[0], point_bl[1]-space, 
                  point_tr[0] - point_bl[0], point_tr[1] - point_bl[1]])
plt.show()


You can adjust that variable "space" as you need.

If someone has some more easy ways to do this, please let me know.



--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/aligning-plot-width-with-imshow-contour-width-tp44408p44409.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to