# Examples from pyvista.examples.examples.load_frog_tissues
# =========================================================

# Load data
import numpy as np
import pyvista as pv
from pyvista import examples
data = examples.load_frog_tissues()

# Plot tissue labels as a volume
# First, define plotting parameters
# Configure colors / color bar
clim = data.get_data_range()  # Set color bar limits to match data
cmap = 'glasbey'  # Use a categorical colormap
categories = True  # Ensure n_colors matches number of labels
opacity = 'foreground'  # Make foreground opaque, background transparent
opacity_unit_distance = 1

# Set plotting resolution to half the image's spacing
res = np.array(data.spacing) / 2

# Define rendering parameters
mapper = 'gpu'
shade = True
ambient = 0.3
diffuse = 0.6
specular = 0.5
specular_power = 40

# Make and show plot
pl = pv.Plotter()
_ = pl.add_volume(
    data,
    clim=clim,
    ambient=ambient,
    shade=shade,
    diffuse=diffuse,
    specular=specular,
    specular_power=specular_power,
    mapper=mapper,
    opacity=opacity,
    opacity_unit_distance=opacity_unit_distance,
    categories=categories,
    cmap=cmap,
    resolution=res,
)
pl.camera_position = 'yx'  # Set camera to provide a dorsal view
pl.show()

# SEE ALSO:
#     Frog Tissues Dataset https://docs.pyvista.org/api/examples/dataset_gallery.html#frog-tissues-dataset
#     See this dataset in the Dataset Gallery for more info.
#     Frog Dataset https://docs.pyvista.org/api/examples/dataset_gallery.html#frog-dataset

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code

