|
From: Scott H. <st...@co...> - 2012-09-24 19:24:08
|
I'd like to use the same patch to clip two images that share the same axes, and extract values from the un-clipped region of both arrays. Unfortunately this seems harder than expected. Code & questions below, Thanks! from matplotlib.patches import Polygon import matplotlib.pyplot as plt from numpy import random poly = patches.Circle((5,5), radius=3, fill=False, ec='none') fig = plt.figure() ax = fig.add_subplot(121) ax.autoscale_view(0,0,0) test = random.rand(10,10) im = ax.imshow(test) test1 = random.rand(10,10) # How to prevent automatic axis scaling? ax1 = fig.add_subplot(122, sharex=ax, sharey=ax) im1 = ax1.imshow(test1) ax.add_patch(poly) im.set_clip_path(poly) # Doesn't work b/c poly vertices auto-transformed to display coords by add_patch? ax1.add_patch(poly) im1.set_clip_path(poly) # How to extract non-clipped values instead of full array? clipped_data = im.get_array() plt.show() |