figure of imshow() is too small

后端 未结 4 469
别跟我提以往
别跟我提以往 2020-11-30 01:15

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\')
         


        
4条回答
  •  無奈伤痛
    2020-11-30 02:19

    Update 2020

    as requested by @baxxx, here is an update because 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).

提交回复
热议问题