Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gr.setwindow(-2, 2, -2, 2)
gr.setspace(-0.5, 0.5, 0, 90)
gr.setmarkersize(1)
gr.setmarkertype(gr.MARKERTYPE_SOLID_CIRCLE)
gr.setcharheight(0.024)
gr.settextalign(2, 0)
gr.settextfontprec(3, 0)
x, y, z = gr.gridit(xd, yd, zd, 200, 200)
h = np.linspace(-0.5, 0.5, 20)
gr.surface(x, y, z, 5)
gr.contour(x, y, h, z, 0)
gr.polymarker(xd, yd)
gr.axes(0.25, 0.25, -2, -2, 2, 2, 0.01)
gr.updatews()
y = range(1, 481)
w, h, d = gr.readimage(
os.path.join(os.path.dirname(os.path.realpath(__file__)),
'surf.png'))
z = [
x & 0xff
for x in d
]
gr.setviewport(0, 1, 0, 1)
gr.setwindow(1, 480, 1, 480)
gr.setspace(1, 1000, 30, 80)
gr.setcolormap(3)
gr.surface(x, y, z, 6)
gr.contour(x, y, range(1), z, 0)
gr.updatews()
self.Refresh()
event.Skip()
def draw(self):
"""
Draw the figure using the renderer
"""
flags = gr.inqregenflags()
if not flags & gr.MPL_SUPPRESS_CLEAR:
gr.clearws()
self.renderer.configure()
self.figure.draw(self.renderer)
if not flags & gr.MPL_POSTPONE_UPDATE:
gr.updatews()
def draw(self):
"""
Draw the figure using the renderer
"""
flags = gr.inqregenflags()
if not flags & gr.MPL_SUPPRESS_CLEAR:
gr.clearws()
self.renderer.configure()
self.figure.draw(self.renderer)
if not flags & gr.MPL_POSTPONE_UPDATE:
gr.updatews()
except (IOError):
continue
gr.clearws()
spectrum[:, 255] = power[:256]
spectrum = np.roll(spectrum, 1)
gr.setcolormap(-113)
gr.setviewport(0.05, 0.95, 0.1, 1)
gr.setwindow(t * dt, (t + 255) * dt, 0, df)
gr.setscale(gr.OPTION_FLIP_X)
gr.setspace(0, 200, 30, 80)
gr3.surface((t + np.arange(256)) * dt, np.linspace(0, df, 256), spectrum, 4)
gr.setscale(0)
gr.axes3d(0.2, 0.2, 0, (t + 255) * dt, 0, 0, 5, 5, 0, -0.01)
gr.titles3d('t [s]', 'f [kHz]', '')
gr.updatews()
t += 1
gr.setfillintstyle(1)
gr.setfillcolorind(bgcolor)
gr.fillrect(xmin, xmax, ymin, ymax)
charheight = 0.024 * (viewport[3] - viewport[2])
gr.setcharheight(charheight)
gr.axes(xtick, ytick, xmin, ymin, majorx, majory, 0.01)
gr.axes(xtick, ytick, xmax, ymax, -majorx, -majory, -0.01)
if grid:
gr.grid(xtick, ytick, xmax, ymax, majorx, majory)
gr.setlinetype(linetype)
gr.polyline(n, x, y)
if markertype != gr.MARKERTYPE_DOT:
gr.setmarkertype(markertype)
gr.polymarker(n, x, y)
if update:
gr.updatews()
def draw(self):
"""
Draw the figure using the renderer
"""
gr.clearws()
renderer = RendererGR(self.figure.dpi)
self.figure.draw(renderer)
gr.updatews()
def plot_domain(color_func, f, re=(-1, 1), im=(-1, 1), N=100, n=15):
w = func_vals(f, re, im, N)
domc = color_func(w, n) * 255
width, height = domc.shape[:2]
domc = np.append(domc, np.ones((width, height, 1)) * 255, axis=2)
domc = domc.astype(np.uint8)
domc = domc.view('
gr.settextfontprec(2, gr.TEXT_PRECISION_STRING)
gr.setcharheight(0.032)
gr.settextcolorind(1)
gr.textext(0.05, 0.95, 'Damped Pendulum')
gr.setcharheight(0.040)
gr.mathtex(0.4, 0.22, '\\omega=\\dot{\\theta}')
gr.mathtex(0.4, 0.1, '\\dot{\\omega}=-\\gamma\\omega-\\frac{g}{l}sin(\\theta)')
gr.setcharheight(0.028)
gr.textext(0.05, 0.22, 't:%7.2f' % t)
gr.textext(0.05, 0.16, '\\theta:%7.2f' % (theta / pi * 180))
gr.settextcolorind(4)
gr.textext(0.05, 0.10, '\\omega:%7.2f' % omega)
gr.settextcolorind(2)
gr.textext(0.05, 0.04, 'y_{A}:%6.2f' % acceleration)
gr.updatews()