Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

390
Views
How to plot a 2d matrix in python with colorbar? (like imagesc in Matlab)

In Matlab I can visualize a matrix data quite easily with

data = rand(10,10); % Createas a 10 x 10 random matrix
imagesc(data);
colorbar;

Now I want to do the same thing in python. I already know how to plot a 2d matrix (numpy array):

from matplotlib.pyplot import imshow
import numpy as np
data = np.random.random((10,10))
imshow(np.asarray(img))

but I don't know how to add a colorbar to it. Any ideas?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

import numpy as np
import matplotlib.pyplot as plt

plt.imshow(np.random.random((50,50)))
plt.colorbar()
plt.show()
over 4 years ago · Santiago Trujillo Report

0

Another possibility is to use plt.matshow()

import numpy as np
import matplotlib.pyplot as plt

plt.matshow(np.random.random((50,50)));
plt.colorbar()
plt.show()

https://matplotlib.org/api/_as_gen/matplotlib.pyplot.matshow.html

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!