Skip to content

Add matplotlib style file for plots - #36

Draft
moprak-nrel wants to merge 1 commit into
kynema:mainfrom
moprak-nrel:plot-style
Draft

Add matplotlib style file for plots#36
moprak-nrel wants to merge 1 commit into
kynema:mainfrom
moprak-nrel:plot-style

Conversation

@moprak-nrel

Copy link
Copy Markdown
Contributor

Start of PR to demonstrate adding a consistent style to plots

@lawrenceccheung
lawrenceccheung self-requested a review April 2, 2025 22:34

@lawrenceccheung lawrenceccheung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, this is an excellent idea. I was able to play with this. These are the old style plots:
image
and this is using the style file:
image

Comment thread util/project.mplstyle
ytick.labelsize: x-small # font size of the tick labels
legend.fontsize: 10
figure.titlesize: large # size of the figure title (``Figure.suptitle()``)
figure.labelsize: large # size of the figure label (``Figure.sup[x|y]label()``)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm using an older version of matplotlib (v3.5.1) or something. Mine complains that

Bad key figure.labelsize in file project.mplstyle, line 23 ('figure.labelsize:   large   # size of the figure label (``Figure.sup[x|y]label()``)')

But it works if I comment this out

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking! Yes, it seems like I have v3.10.x and higher. I can poke at this to see if there might be backward compatible options for the label sizes.

Comment thread util/project.mplstyle
font.family: cm # Make the default font consistent

# Set a default group for line colors and dash styles
axes.prop_cycle: cycler('color', [ "#EE2E2F", "#185AA9", "#008C48", "#F47D23", "#662C91", "#A21D21", "#B43894", "#010202"]) + cycler('linestyle', [ [], [10, 5], [10, 4, 3, 4], [3, 3], [10, 4, 3, 4, 3, 4], [3, 2,6,2], [3,4,1,4], [1,1] ])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a complaint from matplotlib that

Bad value in file 'project.mplstyle', line 31 ('axes.prop_cycle: cycler('color', [ "#EE2E2F", "185AA9", "008C48", "F47D23", "662C91", "A21D21", "B43894", "010202"]) + cycler('linestyle', [ [], [10, 5], [10, 4, 3, 4], [3, 3], [10, 4, 3, 4, 3, 4], [3, 2,6,2], [3,4,1,4], [1,1] ])'): Key axes.prop_cycle: 'cycler('color', [ "' is not a valid cycler construction: EOL while scanning string literal (, line 1)

I think this got fixed in later versions, but it is interpreting the # in #EE2E2F as a comment, so it's not reading the rest of the line. However, by removing the # marks, my version of matplotlib still knows to read those as colors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants