Page 1 of 1

MicPy image generation

Posted: Tue Mar 25, 2025 5:59 pm
by matt_hughes
Hi MICRESS Forum,

Is it possible to change the scales of this plot to more realistic sizes. How do i change the concentration bar to be smaller so that the image isn't too small?

please see image of plot attached as well as an image of the python code used.

Thanks,
Matthew

Re: MicPy image generation

Posted: Wed Mar 26, 2025 11:30 am
by beiz
Hi Matthew,

if you have the newest version of MicPy. It is possible to output the colorbar by bin.plot() function. You can remove the original one, and define you own colorbar as you wish. I have here an example code.
from micpy import bin
import matplotlib.pyplot as plt

path = "B003_1Grain_GrowthFromLiquid_0.frac"

file = bin.File(path)
file.open()
series = file.read()
field = series.get_field(-1)

# output fig, ax, and colorbar objects
fig, ax, cbar=bin.plot(field=field)
cbar.remove() # remove the original colorbar

# define a new colorbar (https://matplotlib.org/stable/api/_as_g ... orbar.html)
im = ax.images[0]
cbar1 = fig.colorbar(im, ax=ax, shrink = 0.5, pad = 0.1)

# define a new colorbar horizontally
cbar2 = fig.colorbar(im, ax=ax, orientation = "horizontal", pad = 0.15)
Image


I hope that it hopes you.

Best Regards
Bei Zhou