Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed

Conversation

tacaswell
Copy link
Member

 - add a cleanup decorator out of paranoia - deepcopy rather than copy colormaps that we mutate
@tacaswelltacaswell added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelMar 15, 2017
@tacaswelltacaswell added this to the2.0.1 (next bug fix release) milestoneMar 15, 2017
Only mask out as 'bad' pixels which have alpha == 0
@tacaswell
Copy link
MemberAuthor

This does not seem to fix the problem 😞

@tacaswell
Copy link
MemberAuthor

This is trying to fix as issue brought up in the comments of#8024 which was in turn fixing#8012

@tacaswelltacaswell removed the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelApr 3, 2017
@tacaswell
Copy link
MemberAuthor

@QuLogic We are going to unblock this for 2.0.1 to prevent the perfect from becoming the enemy of the good.

@QuLogicQuLogic modified the milestones:2.0.1 (next bug fix release),2.0.2 (next bug fix release)May 3, 2017
@QuLogic
Copy link
Member

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?

@tacaswell
Copy link
MemberAuthor

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
Copy link
Member

QuLogic commentedMay 14, 2017
edited
Loading

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:
result-blue
and with 2.0.1:
result-blue
I changed the background patch to red which you can see bleeding through a bit more obviously in the second image.

@tacaswell
Copy link
MemberAuthor

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)

so

and eroding the mask (because high is the pixels to exclude) by 2 gives

so

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()

@QuLogic
Copy link
Member

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 isimshow, Ithink that comes out of the central point and not the corners, so it doesn't know about edge pixels. I'm not sure how easy it would be to change this clipping.

@tacaswelltacaswell added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelJul 10, 2017
@tacaswelltacaswell modified the milestones:2.0.3 (next bug fix release),2.1 (next point release)Jul 10, 2017
@tacaswelltacaswell removed the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelAug 7, 2017
@tacaswell
Copy link
MemberAuthor

Super-sceded by#8966

@tacaswelltacaswell deleted the fix_imshow_edges branchAugust 7, 2017 19:49
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
v2.1
Development

Successfully merging this pull request may close these issues.

3 participants
@tacaswell@QuLogic@dstansby

[8]ページ先頭

©2009-2025 Movatter.jp