Open wd15 opened 4 years ago
Code for plotting the microstructure with a gray scale:
import pyvista as pv
import numpy as np
pv.set_plot_theme("document")
values = np.linspace(0, 10, 1000).reshape((20, 5, 10))
data = np.load('3d.npy')
print(data.shape)
print(values.shape)
values = data[9]
# Create the spatial reference
grid = pv.UniformGrid()
# Set the grid dimensions: shape + 1 because we want to inject our values on
# the CELL data
grid.dimensions = np.array(values.shape) + 1
# Edit the spatial reference
grid.origin = (100, 33, 55.6) # The bottom left corner of the data set
grid.spacing = (1, 1, 1) # These are the cell sizes along each axis
# Add the data values to the cell data
grid.cell_arrays["values"] = values.flatten(order="F") # Flatten the array!
# Now plot the grid!
# import ipdb; ipdb.set_trace()
# pv.remove_scalar_bar()
# plotter = pv.Plotter(off_screen=True)
# plotter.add_mesh(grid)#,
# import ipdb; ipdb.set_trace()
# plotter.show(screenshot='plot1.png', show_edges=False)
grid.plot(show_edges=False, cmap=['black', 'grey', 'white'], show_axes=False, show_scalar_bar=False, off_screen=False, screenshot='plot4.png')
Code for plotting correlations with pyvista