Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're dealing with a regular grid, just treat it as an image:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt nrows, ncols = 1000, 1000 z = 500 * np.random.random(nrows * ncols).reshape((nrows, ncols)) plt.imshow(z, interpolation='nearest') plt.colorbar() plt.show() </code></pre> <p><img src="https://i.stack.imgur.com/dQwwh.png" alt="enter image description here"></p> <p>If you have randomly ordered x,y,z triplets that make up a regular grid, then you'll need to grid them. </p> <p>Essentially, you might have something like this:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt # Generate some data nrows, ncols = 1000, 1000 xmin, xmax = -32.4, 42.0 ymin, ymax = 78.9, 101.3 dx = (xmax - xmin) / (ncols - 1) dy = (ymax - ymin) / (ncols - 1) x = np.linspace(xmin, xmax, ncols) y = np.linspace(ymin, ymax, nrows) x, y = np.meshgrid(x, y) z = np.hypot(x - x.mean(), y - y.mean()) x, y, z = [item.flatten() for item in (x,y,z)] # Scramble the order of the points so that we can't just simply reshape z indicies = np.arange(x.size) np.random.shuffle(indicies) x, y, z = [item[indicies] for item in (x, y, z)] # Up until now we've just been generating data... # Now, x, y, and z probably represent something like you have. # We need to make a regular grid out of our shuffled x, y, z indicies. # To do this, we have to know the cellsize (dx &amp; dy) that the grid is on and # the number of rows and columns in the grid. # First we convert our x and y positions to indicies... idx = np.round((x - x.min()) / dx).astype(np.int) idy = np.round((y - y.min()) / dy).astype(np.int) # Then we make an empty 2D grid... grid = np.zeros((nrows, ncols), dtype=np.float) # Then we fill the grid with our values: grid[idy, idx] = z # And now we plot it: plt.imshow(grid, interpolation='nearest', extent=(x.min(), x.max(), y.max(), y.min())) plt.colorbar() plt.show() </code></pre> <p><img src="https://i.stack.imgur.com/gl1oh.png" alt="enter image description here"></p>
    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. 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