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

Multivar imshow#30597

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

Open
trygvrad wants to merge3 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromtrygvrad:multivar_imshow
Open

Conversation

trygvrad
Copy link
Contributor

Exposes the functionality ofMultiNorm,BivarColormap andMultivarColormap to the top level plotting functionsax.imshow(),ax.pcolor() andax.pcolormesh(). This coloses#30526, seeBivariate and Multivariate Colormapping
As a side-effect of the pcolor/pcolormesh implementation,Collection also gets the new functionality.

!! This PR builds upon#30511, which should be merged first !!

In short, this PR allows you to plot multivariate data more easily, but it does not:

  • Create equivalents to fig.colorbar() for BivarColormap and MultivarColormap to work with ColorizingArtist
  • Select bivariate and multivariate colormaps to include in matplotlib
  • Examples demonstrating the new functionality

These will come in later PRs. SeeBivariate and Multivariate Colormapping

Examples demonstrating new functionality:

importnumpyasnpimportmatplotlibasmplimportmatplotlib.pyplotaspltcmap=mpl.bivar_colormaps['BiPeak']x_0=np.arange(25,dtype='float32').reshape(5,5)%5x_1=np.arange(25,dtype='float32').reshape(5,5).T%5x_0,x_1=x_0+0.3*x_1,x_0*-0.3+x_1,fig,axes=plt.subplots(1,3,figsize=(6,2))axes[0].imshow(x_0,cmap=cmap[0])axes[1].imshow(x_1,cmap=cmap[1])axes[2].imshow((x_0,x_1),cmap=cmap)axes[0].set_title('data 0')axes[1].set_title('data 1')axes[2].set_title('data 0 and 1')
image
fig,axes=plt.subplots(1,6,figsize=(10,2.3))axes[0].imshow((x_0,x_1),cmap='BiPeak',interpolation='nearest')axes[1].matshow((x_0,x_1),cmap='BiPeak')axes[2].pcolor((x_0,x_1),cmap='BiPeak')axes[3].pcolormesh((x_0,x_1),cmap='BiPeak')x=np.arange(5)y=np.arange(5)X,Y=np.meshgrid(x,y)axes[4].pcolormesh(X,Y, (x_0,x_1),cmap='BiPeak')patches= [mpl.patches.Wedge((.3,.7),.1,0,360),# Full circlempl.patches.Wedge((.7,.8),.2,0,360,width=0.05),# Full ringmpl.patches.Wedge((.8,.3),.2,0,45),# Full sectormpl.patches.Wedge((.8,.3),.2,22.5,90,width=0.10),# Ring sector]colors_0=np.arange(len(patches))//2colors_1=np.arange(len(patches))%2p=mpl.collections.PatchCollection(patches,cmap='BiPeak',alpha=0.5)p.set_array((colors_0,colors_1))axes[5].add_collection(p)axes[0].set_title('imshow')axes[1].set_title('matshow')axes[2].set_title('pcolor')axes[3].set_title('pcolormesh (C)')axes[4].set_title('pcolormesh (X, Y, C)')axes[5].set_title('PatchCollection')fig.tight_layout()
image

improved testing for colorizer+multinormApply suggestions from code reviewCo-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>updates based on feedback from@QuLogic
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
Milestone
v3.12.0
Development

Successfully merging this pull request may close these issues.

2 participants
@trygvrad@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp