I'm trying to visualize a numpy array using imshow() since it's similar to imagesc() in Matlab.
imshow(random.rand(8, 90), interpolation='nearest')
The resulting figure is very small at the center of the grey window, while most of the space is unoccupied. How can I set the parameters to make the figure larger? I tried figsize=(xx,xx) and it's not what I want. Thanks!
This question is related to
python
numpy
matplotlib
random.rand
is deprecated meanwhile.This works with matplotlip 3.2.1:
from matplotlib import pyplot as plt
import random
import numpy as np
random = np.random.random ([8,90])
plt.figure(figsize = (20,2))
plt.imshow(random, interpolation='nearest')
This plots:
To change the random number, you can experiment with np.random.normal(0,1,(8,90))
(here mean = 0, standard deviation = 1).
That's strange, it definitely works for me:
from matplotlib import pyplot as plt
plt.figure(figsize = (20,2))
plt.imshow(random.rand(8, 90), interpolation='nearest')
I am using the "MacOSX" backend, btw.
I'm new to python too. Here is something that looks like will do what you want to
axes([0.08, 0.08, 0.94-0.08, 0.94-0.08]) #[left, bottom, width, height]
axis('scaled')`
I believe this decides the size of the canvas.
Source: Stackoverflow.com