I'm trying to make a figure like this. A matrix of plots, each is a visualization of a numerical matrix.
I thought code should look something like the following:
using PyPlot
figure()
for i in 1:100
subplot(10, 10, i)
matshow(rand(10, 10))
end
But the plots would pop out in new windows independently, instead of in separate parts of the same figure. What did I do wrong?
Thanks in advance for your time!
Disclaimer: I've absolutely no experience with Julia. So there may be some caveats about the following I'm not aware of.
From the matshow documentation:
matplotlib.pyplot.matshow(A, fignum=None, **kw)
Display an array as a matrix in a new figure window. [...]fignum:
[ None | integer | False ]
By default, matshow() creates a new figure window with automatic numbering. If fignum is given as an integer, the created figure will use this figure number. Because of how matshow() tries to set the figure aspect ratio to be the one of the array, if you provide the number of an already existing figure, strange things may happen. Iffignum
is False or 0, a new figure window will NOT be created.
Two possible options might thus be:
Use fignum=false
figure()
for i in 1:100
subplot(10, 10, i)
matshow(rand(10, 10), fignum=false)
end
Use imshow
instead of matshow
(because imshow
does not create a new figure by default)
figure()
for i in 1:100
subplot(10, 10, i)
imshow(rand(10, 10))
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With