Skip to content

Add matplotlib style file for plots #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

moprak-nrel
Copy link
Collaborator

Start of PR to demonstrate adding a consistent style to plots

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

@lawrenceccheung lawrenceccheung left a comment

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

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
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
Collaborator 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.

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
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