python - How to make matplotlib clipping to work on plot generated by rbf -
i use patch on plot show points in circle, problem using image generated rbf
, not work.
here last code tried :
from scipy import interpolate import numpy np import matplotlib.pyplot plt import matplotlib.patches patches x, y, z = 10 * np.random.random((3,10)) xi, yi = np.linspace(x.min(), x.max(), 100), np.linspace(y.min(), y.max(), 100) xi, yi = np.meshgrid(xi, yi) rbf = interpolate.rbf(x, y, z, function='linear') zi = rbf(xi, yi) fig1 = plt.figure(figsize=(4, 4), facecolor='white') ax = fig1.add_subplot(111) ax.imshow(zi, vmin=z.min(), vmax=z.max(), origin='lower', extent=[x.min(), x.max(), y.min(), y.max()]) = ax.scatter(x,y) patch = patches.circle((1,1),radius=1,fc='none') ax.add_patch(patch) something.set_clip_path(patch) fig1.show()
i getting following result, can see values showed in whole rectangle, not in circle:
if set position , radius of circle such includes points random set, work expected. clip image itself, need set clip patch image well.
from scipy import interpolate import numpy np; np.random.seed(1) import matplotlib.pyplot plt import matplotlib.patches patches x, y, z = 10 * np.random.random((3,10)) xi, yi = np.linspace(x.min(), x.max(), 100), np.linspace(y.min(), y.max(), 100) xi, yi = np.meshgrid(xi, yi) rbf = interpolate.rbf(x, y, z, function='linear') zi = rbf(xi, yi) fig1 = plt.figure(figsize=(4, 4), facecolor='white') ax = fig1.add_subplot(111) im = ax.imshow(zi, vmin=z.min(), vmax=z.max(), origin='lower', extent=[x.min(), x.max(), y.min(), y.max()]) = ax.scatter(x,y, c="crimson") patch = patches.circle((4,4),radius=3,fc='none') ax.add_patch(patch) something.set_clip_path(patch) im.set_clip_path(patch) plt.show()
Comments
Post a Comment