Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fix imshow edges#8300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Fix imshow edges#8300
Uh oh!
There was an error while loading.Please reload this page.
Conversation
- add a cleanup decorator out of paranoia - deepcopy rather than copy colormaps that we mutate
Only mask out as 'bad' pixels which have alpha == 0
This does not seem to fix the problem 😞 |
@QuLogic We are going to unblock this for 2.0.1 to prevent the perfect from becoming the enemy of the good. |
So I've had a chance to confirm that this PR does not correct the issue with Cartopy. Is there hope for pursuing an amendment to this PR or do you think a completely different approach is needed? |
I am not sure, still suspect that this is the right general direction, but it will depend on exactly what cartopy is feeding in (which I could not dig through the layers to sort out). |
QuLogic commentedMay 14, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I extracted the data and outline path used by Cartopy and put it intoa gist here that uses only Matplotlib. Here's the blue image with 2.0.0: |
On a bit deeper inspection I am not sure if this is something that can / should be fixed on the matplotlib side. Tweaking the example a bit I think the issue is that the data / mask are a few pixel too small. Marking the bad pixels as pink and zooming in gives (ignoring the non-clipping of the patch) and eroding the mask (because high is the pixels to exclude) by 2 gives importnumpyasnpimportmatplotlibasmplimportmatplotlib.pyplotaspltimportmatplotlib.patchesasmpatchesimportmatplotlib.pathasmpathimportosimportscipy.ndimage.morphologyimportmatplotlib.cmasmcmplt.style.use('classic')# os.chdir('/tmp/b8ebfd6e1bfc304d39487750bc2a48be')data=np.load('cp-data.npz')path=mpath.Path(vertices=data['verts'],codes=data['codes'],_interpolation_steps=data['steps'],readonly=data['ro'])imshow_kwargs= {'vmin':None,'vmax':None,'resample':None,'filterrad':4.0,'alpha':None,'filternorm':1,'aspect':None,'interpolation':'none','cmap':None,'data':None,'url':None,'shape':None,'extent': [-20037508.342789244,20037508.342789244,-8683259.716434667,8683259.716434667],'norm':None,'imlim':None,'origin':'lower'}forcolorin ['fc','red','green','blue']:mask=data[color+'_mask']# mask = scipy.ndimage.morphology.binary_erosion(mark, iterations=2)img=np.ma.MaskedArray(data[color+'_data'],mask)fig,ax=plt.subplots(figsize=(10,5))background=mpatches.PathPatch(path,edgecolor='none',facecolor='red',zorder=-1,clip_on=False,transform=ax.transData)ax.add_patch(background)outline=mpatches.PathPatch(path,edgecolor='black',facecolor='none',zorder=2.5,clip_on=False,transform=ax.transData)ax.add_patch(outline)# Not necessary?ax.patch=backgroundifcolor!='fc':cmap=mcm.get_cmap(color.title()+'s')cmap.set_bad('pink')imshow_kwargs['cmap']=cmapelse:imshow_kwargs['cmap']=Noneax.imshow(img,**imshow_kwargs)ax.set_title('%s %s'% (color,mpl.__version__))fig.savefig('result-'+color+'.png')plt.show() |
From what I can tell, Cartopy determines the mask from the points that don't transform back to a valid point in the source domain. But since this is |
Super-sceded by#8966 |
attn@QuLogic