Closed mezarque closed 4 months ago
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
I haven't fully reviewed the
mpl
changes, but I made a couple suggestions to start a discussion. I am not sure how much research you've done around available tools, but I would check these two tools as potential inspiration: https://github.com/raybuhr/pyplot-themes and https://github.com/lgienapp/aquarel
Thanks for pointing me to these! I do like how aquarel
uses with
to specify a context for plotting; this could save users from having to have to call autostyle
at the end of plots. I think both packages do some of the things we need to accomplish, but not all. Configurability/ usability is also something we want to consider, since I think users may not know what changes they want to make in advance of generating a plot. Let's explore these different approaches through some user testing.
I think I addressed most of the comments above - thanks for all the feedback! My main concern with the renamings is that all of the functions are now quite verbose, which feels clunky / ugly to use. But maybe that's just the sacrifice we have to make for clarity.
Should I write tests for the functionality in this PR, or wait for another PR?
What happened to the tests? They seem to have disappeared from the CI workflow.
I'm not sure where you're looking, but at least in my view of the PR, the tests are still running (and if you look at the Actions tab, it seems like they're working still?)
I addressed the remaining comments; lmk if you have any further Qs!
PR checklist
Overview
This PR adds in automatic styling functionality for
matplotlib
, giving users the ability to more easily perform style modifications to plots. The modifications occur primarily through two parts of the API:apc.mpl.setup()
:ListedColormaps
), and gradients (asLinearSegmentedColormaps
) intomatplotlib
with prefixapc:
matplotlib
stylesheet (arcadia_2024.mplstyle
), updating the defaults inrcParams
.apc.mpl.autostyle()
matplotlib
rcParams
doesn't allow you to control everything, this is needed to get the remaining ~20% towards correct stylemono
argument, alters font of user-chosen ticklabels to be "Suisse Int'l Mono"cat
argument, removes ticks and capitalizes ticklabels for categorical axes (e.g. for violin or bar plots)cbar
argument, alters the font of the tick labels of any colorbars to be "Suisse Int'l Mono"In addition to those major functions, there's some auxiliary functionality to help figures conform to fixed size guidelines, which are provided via existing templates in our Adobe Creative Cloud library.
apc.dimensions()
plt.subplots(figsize = <>)
"full_w"
,"full_s"
,"threeq_w"
,"threeq_s"
,"half_s"
apc.SAVE_WEB
andapc.SAVE_PRINT
plt.savefig(**apc.SAVE_WEB)
to make sure margins, etc. are of the correct sizeDrive-by (is this the proper usage of this? I can't find references online):
classes.py
module into one module for each class,hexcode.py
,gradient.py
, andpalette.py
There's a lot going on here, and I'm sure we'll have a lively discussion about things like naming, what to expose to users, organization, namespaces, etc. Looking forward to lots of feedback!
Testing
I confirmed that things work as expected by testing the functionality in
usage_example.ipynb
, which goes into some detail about what all is going on and how users might use the various functions.Halp
CI is failing right now; it seems that
impresources
is not finding thearcadia_2024.mplstyle
file and is returningNone
. I am not sure how to resolve this, and would love some help figuring out how to get the CI to work properly; this error does not show up when I runpytest .
on my local clone.TODO
These are things that I'd like to figure out, but haven't yet found an elegant way to implement.
matplotlib
and detect collisions there?seaborn
, the marker sizes of legend elements can be really small (equivalent to the size of points in the scatter plot). This is bad b/c it's hard to tell what is a scatter plot point vs. a legend marker. There are lots of ugly ways to solve this problem, some of which involve just creating a new legend, but it's kind of annoying. Would be nice to have a declarative way to do this, e.g.apc.mpl.scale_legend_markers(2)
or something.