0

I am trying to draw a Brownian motion on top of the following canvas:

import matplotlib
import matplotlib.pyplot as plt

palette = matplotlib.colors.ListedColormap(['#F08080'])
gridCells = np.ones((50, 50)) * np.nan
gridCells.shape
N=50
for j in range(10)[::-1]:
    gridCells[N//4 - j : N//4 + j +1, N//4 - j - 25 : N//4 + j - 25 +1] = j
# Draw
fig, ax = plt.subplots(1, 1, tight_layout=True)
# NaN values (i.e. bad) stay white
palette.set_bad(color='w', alpha=0)
for x in range(N + 1):
    ax.axhline(x, color='k', zorder=1)
    ax.axvline(x, color='k', zorder=1)
ax.imshow(gridCells, interpolation='none', cmap=palette, extent=[0, N, 0, N], zorder=0)
ax.axis('off')

How may I now draw a brownian motion overlaying this canvas?

Thank you in advance for your help anyone!

COxf
  • 45
  • 4
  • could you be a little more specific? do you want the grid cells to move around? – Paul H Nov 18 '20 at 22:10
  • @PaulH - I am trying to essentially draw on top of the canvas - as if in Paint I would select a grid cell as a starting point, put my brush on it and then randomly walk from cell to cell on the grid canvas. – COxf Nov 19 '20 at 11:16
  • are you asking how to generate the trace? or do you already have the trace and need to know how to plot it? – Paul H Nov 19 '20 at 12:59
  • I already have the trace (i.e. a function to generate Brownian motion) but do not know how to do it over the cell of the grid canvas. – COxf Nov 19 '20 at 13:06
  • does this help? https://stackoverflow.com/questions/34458251/plot-over-an-image-background-in-python/34459284#34459284 – Paul H Nov 19 '20 at 14:22
  • Unfortunatelly not I am not getting it to work with the way I set up the grid – COxf Nov 19 '20 at 20:38
  • Well, there's nothing I can really add to that without you showing me exactly what you've tried – Paul H Nov 19 '20 at 21:44

0 Answers0