Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
width, height = z.shape
cmap = _colormap()
icmap = np.zeros(256, np.uint32)
for i in range(256):
r, g, b, a = cmap[i]
icmap[i] = (int(r*255) << 0) + (int(g*255) << 8) + (int(b*255) << 16) + (int(a*255) << 24)
z_range = np.ptp(z)
if z_range > 0:
data = (z - np.min(z)) / z_range * 255
else:
data = np.zeros((width, height))
rgba = np.zeros((width, height), np.uint32)
for x in range(width):
for y in range(height):
rgba[x, y] = icmap[int(data[x, y])]
gr.drawimage(x_min, x_max, y_min, y_max, width, height, rgba)
_colorbar()
elif kind == 'wireframe':
if x.shape == y.shape == z.shape:
x, y, z = gr.gridit(x, y, z, 50, 50)
gr.setfillcolorind(0)
z.shape = np.prod(z.shape)
gr.surface(x, y, z, gr.OPTION_FILLED_MESH)
_draw_axes(kind, 2)
elif kind == 'surface':
if x.shape == y.shape == z.shape:
x, y, z = gr.gridit(x, y, z, 200, 200)
z.shape = np.prod(z.shape)
if _plt.kwargs.get('accelerate', True):
gr3.clear()
gr3.surface(x, y, z, gr.OPTION_COLORED_MESH)
def draw_mathtext(self, x, y, angle, Z):
h, w = Z.shape
img = np.zeros((h, w), np.uint32)
for i in range(h):
for j in range(w):
img[i, j] = (255 - Z[i, j]) << 24
a = int(angle)
if a == 90:
gr.drawimage(x - h, x, y, y + w, h, w,
np.resize(np.rot90(img, 1), (h, w)))
elif a == 180:
gr.drawimage(x - w, x, y - h, y, w, h, np.rot90(img, 2))
elif a == 270:
gr.drawimage(x, x + h, y - w, y, h, w,
np.resize(np.rot90(img, 3), (h, w)))
else:
gr.drawimage(x, x + w, y, y + h, w, h, img)
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('
def draw_mathtext(self, x, y, angle, Z):
h, w = Z.shape
img = np.zeros((h, w), np.uint32)
for i in range(h):
for j in range(w):
img[i, j] = (255 - Z[i, j]) << 24
a = int(angle)
if a == 90:
gr.drawimage(x - h, x, y, y + w, h, w,
np.resize(np.rot90(img, 1), (h, w)))
elif a == 180:
gr.drawimage(x - w, x, y - h, y, w, h, np.rot90(img, 2))
elif a == 270:
gr.drawimage(x, x + h, y - w, y, h, w,
np.resize(np.rot90(img, 3), (h, w)))
else:
gr.drawimage(x, x + w, y, y + h, w, h, img)
w = width / height * (viewport[3] - viewport[2])
x_min = max(0.5 * (viewport[0] + viewport[1] - w), viewport[0])
x_max = min(0.5 * (viewport[0] + viewport[1] + w), viewport[1])
y_min = viewport[2]
y_max = viewport[3]
else:
h = height / width * (viewport[1] - viewport[0])
x_min = viewport[0]
x_max = viewport[1]
y_min = max(0.5 * (viewport[3] + viewport[2] - h), viewport[2])
y_max = min(0.5 * (viewport[3] + viewport[2] + h), viewport[3])
_set_colormap()
gr.selntran(0)
if isinstance(image, basestring):
gr.drawimage(x_min, x_max, y_min, y_max, width, height, data)
else:
gr.cellarray(x_min, x_max, y_min, y_max, width, height, data)
if 'title' in _plt.kwargs:
gr.savestate()
gr.settextalign(gr.TEXT_HALIGN_CENTER, gr.TEXT_VALIGN_TOP)
gr.textext(0.5 * (viewport[0] + viewport[1]), vp[3], _plt.kwargs['title'])
gr.restorestate()
gr.selntran(1)
def draw_mathtext(self, x, y, angle, Z):
h, w = Z.shape
img = np.zeros((h, w), np.uint32)
for i in range(h):
for j in range(w):
img[i, j] = (255 - Z[i, j]) << 24
a = int(angle)
if a == 90:
gr.drawimage(x - h, x, y, y + w, h, w,
np.resize(np.rot90(img, 1), (h, w)))
elif a == 180:
gr.drawimage(x - w, x, y - h, y, w, h, np.rot90(img, 2))
elif a == 270:
gr.drawimage(x, x + h, y - w, y, h, w,
np.resize(np.rot90(img, 3), (h, w)))
else:
gr.drawimage(x, x + w, y, y + h, w, h, img)
def draw_mathtext(self, x, y, angle, Z):
h, w = Z.shape
img = np.zeros((h, w), np.uint32)
for i in range(h):
for j in range(w):
img[i, j] = (255 - Z[i, j]) << 24
a = int(angle)
if a == 90:
gr.drawimage(x - h, x, y, y + w, h, w,
np.resize(np.rot90(img, 1), (h, w)))
elif a == 180:
gr.drawimage(x - w, x, y - h, y, w, h, np.rot90(img, 2))
elif a == 270:
gr.drawimage(x, x + h, y - w, y, h, w,
np.resize(np.rot90(img, 3), (h, w)))
else:
gr.drawimage(x, x + w, y, y + h, w, h, img)
def draw_mathtext(self, x, y, angle, Z):
h, w = Z.shape
img = np.zeros((h, w), np.uint32)
for i in range(h):
for j in range(w):
img[i, j] = (255 - Z[i, j]) << 24
a = int(angle)
if a == 90:
gr.drawimage(x - h, x, y, y + w, h, w,
np.resize(np.rot90(img, 1), (h, w)))
elif a == 180:
gr.drawimage(x - w, x, y - h, y, w, h, np.rot90(img, 2))
elif a == 270:
gr.drawimage(x, x + h, y - w, y, h, w,
np.resize(np.rot90(img, 3), (h, w)))
else:
gr.drawimage(x, x + w, y, y + h, w, h, img)
def draw_mathtext(self, x, y, angle, Z):
h, w = Z.shape
img = np.zeros((h, w), np.uint32)
for i in range(h):
for j in range(w):
img[i, j] = (255 - Z[i, j]) << 24
a = int(angle)
if a == 90:
gr.drawimage(x - h, x, y, y + w, h, w,
np.resize(np.rot90(img, 1), (h, w)))
elif a == 180:
gr.drawimage(x - w, x, y - h, y, w, h, np.rot90(img, 2))
elif a == 270:
gr.drawimage(x, x + h, y - w, y, h, w,
np.resize(np.rot90(img, 3), (h, w)))
else:
gr.drawimage(x, x + w, y, y + h, w, h, img)