Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8001275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:03:08+00:00 2026-06-04T16:03:08+00:00

I have n matrices (np.array) of floats and I want to plot them together

  • 0

I have n matrices (np.array) of floats and I want to plot them together using imshow but with each one having a different colour range for its values. e.g. n = white->blue, n+1 = white -> red etc.
Is there a way of doing this?

The matrices are of the same size, and colouring over each other is not too much of an issue as the majority of the matrices’ values are 0 (hope that will be white).

I was thinking of something like:

1st matrix

000
010
000

2nd matrix

000
000
001

So I thought maybe I could convert the second matrix into:

222
222
223

and then make 0->1 white to blue and 2->3 white to red.

I unfortunately have no idea how to do this with the matplotlib colormaps.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:03:10+00:00Added an answer on June 4, 2026 at 4:03 pm

    imshow will not plot values that are set to None. If the data are sparse enough you can lay them on top of each other.

    import numpy as np
    import pylab as plt
    
    # Your example data
    A1 = np.zeros((3,3))
    A2 = np.zeros((3,3))
    A1[1,1] = 1
    A2[2,2] = 1
    
    # Apply a mask to filter out unused values
    A1[A1==0] = None
    A2[A2==0] = None
    
    # Use different colormaps for each layer
    pwargs = {'interpolation':'nearest'}
    plt.imshow(A1,cmap=plt.cm.jet,**pwargs)
    plt.imshow(A2,cmap=plt.cm.hsv,**pwargs)
    plt.show()
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple NxM matrices and want to select one of them by a
I have both matrices containing only ones and each array has 500 rows and
I have an array of high dimensional however very sparse matrices. I want to
Hello, I have created a multithreaded application for multiplying two matrices using pthreads,but to
I have a cell array which contains 7 matrices of varying column and length
I have two matrices of different sizes. Let's just define matrix {a} as a(1:10)
I have two matrices a and b (with equal number of columns). I want
I have 2 matrices and I need to multiply them and then print the
I have an array (M) of matrices. I perform an operation on the matrix
I have a matrix A and I want 2 matrices U and L such

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.