Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What i can decrypt from your question is that you have an 11 x 19 array and the numbers comprising this array appear to be real numbers in the range 0 &lt;= x &lt;= 1 (obviously neither assumption is critical to the answer).</p> <p>Below is the code to create a heatmap of your array such that the smallest values are lighter and the larger values are darker shades of grey (eg, '0' is white, and '1' is black).</p> <p>So first, create an array <em>identical in shape and value range</em> to yours:</p> <pre><code>import numpy as NP M = NP.random.rand(209).reshape(11, 19) M.shape # returns: (11, 19) # if the array returned from your call to 'genfromtxt' # is not 11 x 19, # then you need to reshape it so that it is, # use, e.g., 'data.reshape(11, 19)' from matplotlib import pyplot as PLT from matplotlib import cm as CM fig = PLT.figure() ax1 = fig.add_subplot(111) </code></pre> <p><strong>gray_r</strong> refers to a particular matplotlib <em>color map</em>--ie, creates a look-up table that maps each of the cell values in your 2D array to a cell color/hue (put another way: <em>color maps</em> just maps a palette to data;</p> <p>the <strong>r</strong> just refers to <em>reverse</em>; i pefer this mapping because it seems more intuitive to me--ie, white is mapped to 0 and larger values are mapped to darker shades of gray;</p> <p>the available colormaps are in the module <strong>cm</strong>; <strong><em>dir(matplotlib.cm)</em></strong> to get a list of the installed colormaps (there are dozens); the <a href="http://matplotlib.org/examples/color/colormaps_reference.html" rel="nofollow noreferrer">Matplotlib Site</a> has an excellent visual display of them (as a set of matplotlib plots of course).</p> <pre><code># select the color map by calling get_cmap and passing in a registered colormap # and an integer value for _lut_ which is just the number of different colors desired cmap = CM.get_cmap('gray_r', 10) # map the colors/shades to your data ax1.imshow(M, interpolation="nearest", cmap=cmap) # plot it PLT.show() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload