You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
import numpy as np
|
|
from matplotlib import pyplot
|
|
|
|
class ResistanceView:
|
|
def __init__(self, maximum=30):
|
|
pyplot.ion()
|
|
self.fig, self.ax = pyplot.subplots()
|
|
self.axim = self.ax.imshow(np.zeros(shape=(9, 10)), interpolation='nearest', cmap='gray', vmin=0, vmax=maximum)
|
|
|
|
def updateView(self, matrix):
|
|
self.axim.set_data(matrix)
|
|
self.fig.canvas.flush_events()
|
|
|
|
class VectorView:
|
|
def __init__(self, vectormap, title=""):
|
|
# Vector origin location
|
|
X = np.repeat(range(9), 10)
|
|
Y = np.resize(range(10), 10*9)
|
|
|
|
# Directional vectors
|
|
U = vectormap[:,:,0] # np.zeros(shape=(90))#
|
|
V = vectormap[:,:,1] # np.zeros(shape=(90))#
|
|
|
|
# Creating plot
|
|
pyplot.quiver(X, Y, U, V, color='b', units='xy', scale=1)
|
|
pyplot.title(title)
|
|
|
|
## x-lim and y-lim
|
|
pyplot.xlim(-1, 9)
|
|
pyplot.ylim(-2, 11)
|
|
|
|
# Show plot with grid
|
|
pyplot.grid()
|
|
pyplot.show()
|