Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 3D plots to notebooks #479

Open
wd15 opened this issue Jun 20, 2020 · 1 comment
Open

Add 3D plots to notebooks #479

wd15 opened this issue Jun 20, 2020 · 1 comment
Milestone

Comments

@wd15
Copy link
Contributor

wd15 commented Jun 20, 2020

Code for plotting correlations with pyvista

import pyvista as pv
import numpy as np

pv.set_plot_theme("document")

data = np.load('corr.npy')
print(data.shape)
values = data[0, :22, :22, :22, 4]

# 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!

grid.plot(show_edges=False, cmap='jet', show_axes=False, show_scalar_bar=False, off_screen=True, screenshot='corr1.png')

#grid.plot(show_edges=False, show_axes=False, show_scalar_bar=False)
@wd15 wd15 added this to the 0.4 milestone Jun 20, 2020
@wd15
Copy link
Contributor Author

wd15 commented Jun 20, 2020

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')

@wd15 wd15 modified the milestones: 0.4, 0.4.1 Jul 2, 2020
@wd15 wd15 modified the milestones: 0.4.1, 0.4.2 Aug 17, 2020
@wd15 wd15 modified the milestones: 0.4.2, 0.5, 0.5.1 Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant