Skip to content

Better plot interface for Python script and Jupyter notebook #14

Description

@BinWang0213

Thanks for your nice Python code for such microstructure modeling.

Is your feature request related to a problem? Please describe.
CLI interface can plot very nice seeds, polymesh and trimesh. But I need write very long code to reproduce the figure, here is an examples

def getPhaseColor(i,phases):
    return phases[i].get('color', 'C' + str(i % 10))

# Create Figure
k = 1
off = 1
len_x = domain.length + 2 * off
len_y = domain.width + 2 * off
plt.figure(figsize=(k * len_x, k * len_y))

# Plot Seeds
seed_colors=[getPhaseColor(s.phase, phases) for s in seeds]
seeds.plot(color=seed_colors, alpha=0.8, edgecolor='k', linewidth=0.3)
domain.plot(facecolor='none', edgecolor='k', linewidth=0.5)

# Add legend
legend_patchs=[]
for ph in phases:
     legend_patchs.append( mpatches.Patch(color=ph["color"], ec='k',label=ph["name"]) )
plt.legend(handles=legend_patchs)
plt.axis('image')
plt.show()

Describe the solution you'd like

# Create Figure
plt.figure(figsize=(5, 5))

seeds.plot(material_name=['Matrix','Void'],color=['C0','C1'], alpha=0.8, edgecolor='k', linewidth=0.3)
domain.plot(facecolor='none', edgecolor='k', linewidth=0.5)

plt.axis('image')
plt.show()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions