OpenCores
URL https://opencores.org/ocsvn/pdp1/pdp1/trunk

Subversion Repositories pdp1

[/] [pdp1/] [trunk/] [sw/] [xyplot.py] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 yannv
import numpy as np
2
import matplotlib.pyplot as plt
3
import matplotlib.colors as colors
4
import matplotlib.animation as animation
5
from random import randint
6
 
7
width=1024
8
height=1024
9
 
10
def generator():
11
    while True:
12
        x = randint(0,width-1)
13
        y = randint(0,height-1)
14
        yield (x,y)
15
 
16
def init():
17
    return [im]
18
 
19
def run(point):
20
    # TODO: This doesn't update the image?
21
    fb = im.get_array()
22
    fb *= 0.99   # decay
23
    if point:     # plot new point
24
        #print point
25
        x,y=point
26
        fb[y,x]=1.0
27
    im.set_array(fb)
28
    return [im]
29
 
30
fig,ax = plt.subplots()
31
# TODO: this is white to green, want black to green?
32
cmap = plt.get_cmap("Greens")
33
#ax.axis('off')
34
fb = np.ndarray((width,height), np.float32)
35
fb.fill(0)
36
#for x in range(width):
37
#    fb[x,:] *= x/float(width)
38
#print fb
39
im = ax.imshow(fb, cmap, colors.Normalize(0,1))
40
 
41
ani = animation.FuncAnimation(fig, run, generator, interval=1)
42
plt.show()
43
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.