Visualization¶
In this section, we'll explore the different ways to visualize field data from MICRESS binary files using MicPy's built-in plotting capabilities based on the Matplotlib library.
VTK Export & ParaView Integration
For advanced 3D visualization and in-depth analysis, MicPy can export data to the Visualization Toolkit (VTK) format, enabling seamless use with external tools such as ParaView. See the VTK Export and ParaView Plugin sections for details on exporting data and visualizing it in ParaView.
Built-In Visualization¶
MicPy provides a built-in method to visualize 2D slices of Field objects. The plot() method returns a Matplotlib Figure, Axes and Colorbar objects.
from micpy.bin import read
# Read the last field from a binary file
field = read("A001_Delta_Gamma.conc1", -1)
# Plot the field using the default settings
fig, ax, cbar = field.plot()

The plot() method also accepts optional arguments axis and index. The axis argument specifies the axis along which the slice is taken, and can be one of the following: x, y, or z. The index argument specifies the slice index, and has to be an integer.
from micpy.bin import read
# Read the last field from a binary file
field = read("A005_Grain_Growth_Misorientation_3D.korn", -1)
# Plot the field along the x-axis
fig, ax, cbar = field.plot(axis="x", index=0)

Customizing the Visualization¶
The plot() method accepts various Matplotlib parameters such as the title, resolution (dpi), and color map (cmap).

You can customize the visualization even further by directly modifying the Matplotlib Figure, Axes and Colorbar objects returned by the plot() method. This allows you to perform any kind of advanced customizations using Matplotlib's extensive functionality.

Combining Multiple Plots¶
You can combine multiple plots into a single figure using Matplotlib's subplots functionality. This allows you to visualize two or more slices of the field data side by side. In the following example, we plot two different fields from the same series in a single figure.

In the example above, each subplot's color map is determined by the minimum and maximum values of the field data. If you want to use identical color maps for both subplots, you can pass the vmin and vmax arguments to the plot() method.

Reference¶
micpy.bin.Field.plot(axis='y', index=0, title=None, xlabel=None, ylabel=None, figsize=None, dpi=None, aspect='equal', ax=None, cax=None, vmin=None, vmax=None, cmap='micpy', alpha=1.0, interpolation='none', extent=None) ¶
Plot a slice of the field using Matplotlib.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis | str | Axis to plot. Possible values are | 'y' |
index | int | Index of the slice. Defaults to | 0 |
title | str | Title of the plot. Defaults to | None |
xlabel | str | Label of the x-axis. Defaults to | None |
ylabel | str | Label of the y-axis. Defaults to | None |
figsize | Tuple[float, float] | Figure size. Defaults to | None |
dpi | int | Figure DPI. Defaults to | None |
aspect | str | Aspect ratio. Defaults to | 'equal' |
ax | Axes | Axes of the plot. Defaults to | None |
cax | Axes | Axes of the color bar. Defaults to | None |
vmin | float | Minimum value of the color bar. Defaults to | None |
vmax | float | Maximum value of the color bar. Defaults to | None |
cmap | str | Colormap. Defaults to | 'micpy' |
alpha | float | Transparency of the plot. Defaults to | 1.0 |
interpolation | str | Interpolation method. Defaults to | 'none' |
extent | Tuple[float, float, float, float] | Extent of the plot. | None |
Returns:
| Type | Description |
|---|---|
Tuple[Figure, Axes, Colorbar] | Matplotlib figure, axes, and color bar. |

