Skip to main content
Code Review

Return to Question

added 4 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

plotting Plotting many images at once in matplotlib

I am using numpy and matplotlib to do a statistical simulation. The simulation itself is pretty fast thanks to numPy vectorizatio, however the plotting is slow since I still use a forfor loop. Here

Here is the result:

enter image description here

Right now, I call matplotlib.pyplot.plt 10000 times - once for each tile in 100 ×ばつ 100 square which can't possibly be optimal, but I can't think of how to do it better:

N = 100
for x in range(N):
 for y in range(N):
 plt.fill( myPath[x,y,0] ,myPath[x,y,1])

Let's say I stored all the varaibles in an numPy array myPath with shape (N,N,2,4) so that myPath[x,y,0] and myPath[x,y,1] give the x and y coordinates of the path.

How do I reduce the number of calls to plt in my visualization?

plotting many images at once in matplotlib

I am using numpy and matplotlib to do a statistical simulation. The simulation itself is pretty fast thanks to numPy vectorizatio, however the plotting is slow since I still use a for loop. Here is the result:

enter image description here

Right now, I call matplotlib.pyplot.plt 10000 times - once for each tile in 100 ×ばつ 100 square which can't possibly be optimal, but I can't think of how to do it better:

N = 100
for x in range(N):
 for y in range(N):
 plt.fill( myPath[x,y,0] ,myPath[x,y,1])

Let's say I stored all the varaibles in an numPy array myPath with shape (N,N,2,4) so that myPath[x,y,0] and myPath[x,y,1] give the x and y coordinates of the path.

How do I reduce the number of calls to plt in my visualization?

Plotting many images at once in matplotlib

I am using numpy and matplotlib to do a statistical simulation. The simulation itself is pretty fast thanks to numPy vectorizatio, however the plotting is slow since I still use a for loop.

Here is the result:

enter image description here

Right now, I call matplotlib.pyplot.plt 10000 times - once for each tile in 100 ×ばつ 100 square which can't possibly be optimal, but I can't think of how to do it better:

N = 100
for x in range(N):
 for y in range(N):
 plt.fill( myPath[x,y,0] ,myPath[x,y,1])

Let's say I stored all the varaibles in an numPy array myPath with shape (N,N,2,4) so that myPath[x,y,0] and myPath[x,y,1] give the x and y coordinates of the path.

How do I reduce the number of calls to plt in my visualization?

edited tags
Link
200_success
  • 145.5k
  • 22
  • 190
  • 479
Source Link

plotting many images at once in matplotlib

I am using numpy and matplotlib to do a statistical simulation. The simulation itself is pretty fast thanks to numPy vectorizatio, however the plotting is slow since I still use a for loop. Here is the result:

enter image description here

Right now, I call matplotlib.pyplot.plt 10000 times - once for each tile in 100 ×ばつ 100 square which can't possibly be optimal, but I can't think of how to do it better:

N = 100
for x in range(N):
 for y in range(N):
 plt.fill( myPath[x,y,0] ,myPath[x,y,1])

Let's say I stored all the varaibles in an numPy array myPath with shape (N,N,2,4) so that myPath[x,y,0] and myPath[x,y,1] give the x and y coordinates of the path.

How do I reduce the number of calls to plt in my visualization?

lang-py

AltStyle によって変換されたページ (->オリジナル) /