Example #1
0
import numpy as np
import matplotlib.pyplot as plt
from numpyviz import VisualArray

arr = np.arange(64).reshape((1, 8, 8))
va = VisualArray(arr)
cells = va.get_indices_chequerwise(window=(1, 1, 1))
va.set_colors(cells.T, color='white', basecolor='grey')
va.vizualize(fixview=True, axis_labels=(None, None, None))
va.ax.dist = 12.5  #zoom out a little
plt.show()
Example #2
0
import numpy as np
import matplotlib.pyplot as plt
from numpyviz import VisualArray

import matplotlib.gridspec as gridspec
arr = np.random.randint(99, size=24).reshape((3, 4, 2))
fig = plt.figure(constrained_layout=True)
spec = gridspec.GridSpec(ncols=5, nrows=1, figure=fig)
ax = fig.add_subplot(spec[0], projection='3d')
ax.set_title(f'body of shape={arr.shape}')
va = VisualArray(arr, fig=fig, ax=ax)
va.set_colors(va.get_indices().T, color='lawngreen', basecolor='aqua')
va.mix_colors(va.get_indices_chequerwise((1, 1, arr.shape[2])).T, 'black')
va.vizualize(fixview=True, axis_labels=('axis=0', 'axis=1', 'axis=2'))

ax = fig.add_subplot(spec[1:], projection='3d')
ax.set_title(f'body of shape={arr.flatten().shape}')
va2 = VisualArray(va.arr.flatten(), fig=fig, ax=ax)
va2.set_colors(va2.get_indices().T, color='lawngreen', basecolor='aqua')
va2.mix_colors(va2.get_indices_chequerwise((1, 1, arr.shape[2])).T, 'black')
va2.vizualize(fixview=True, axis_labels=(None, None, 'axis=0'))
ax.dist = 8
plt.get_current_fig_manager().window.state('zoomed')
plt.show()
Example #3
0
va2a = VisualArray(arr, fig=fig, ax=ax)
va2a.ax.set_title(f'input -> input.swapaxes(0, 1)')

va2a.set_colors(va2a.get_indices().T, color='lightgreen', basecolor='aqua')
va2a.permute(shape)
va2a.vizualize(fixview=True,
               axis_labels=('axis=0+3', 'axis=1', 'axis=2'),
               usetex=False,
               scale=1.2)
va2a.ax.dist = 8

ax = fig.add_subplot(2, 3, 6, projection='3d')
val = VisualArray(va2a.arr.swapaxes(1, 2), fig=fig, ax=ax)
val.ax.set_title(f'input -> input.swapaxes(2, 3)')

val.set_colors(val.get_indices_chequerwise(window=(4, 3, 4)).T,
               color='darkgreen',
               basecolor='lightgreen')
#val.permute((arr2.shape[1]//w[0], arr2.shape[2]//w[1], w[0], w[1]))
val.vizualize(fixview=True,
              axis_labels=('axis=0+3', 'axis=1', 'axis=2'),
              usetex=False,
              scale=1.2)
val.ax.dist = 8

ax = fig.add_subplot(2, 3, 4, projection='3d')
va3 = VisualArray(arr2, fig=fig, ax=ax)
va3.ax.set_title(f'output')
va3.set_colors(va3.get_indices().T, color='lightgreen', basecolor='aqua')
va3.ax.dist = 12
va3.azim, va3.elev = -90, 45