Skip to content

Allow setting MATPLOTLIBRC by process substitution. #9570

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

Merged
merged 1 commit into from
Jan 16, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 25, 2017

This makes (e.g.)

$ MATPLOTLIBRC=<(echo 'savefig.transparent: true') python foo.py

use savefig.transparent: true as contents of matplotlibrc for the
given process (on POSIX).

This generalizes the MPLBACKEND mechanism to all rcParams (although the
lack of "cascading" rc-files means that the "normal" rc-file is
completely hidden -- but that's a separate issue).

Closes #6884.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswell
Copy link
Member

👍 but needs some documentation

@tacaswell tacaswell added this to the v2.2 milestone Oct 31, 2017
@anntzer
Copy link
Contributor Author

anntzer commented Oct 31, 2017

This basically follows normal rules of shell process substitution (on shells that support them). I can add a whatsnew saying that that's supported but I don't really want to explain what process substitution is...

Also, note that this very technically breaks code that assumes that you can read from matplotlib_fname() again (because it's a pipe). In particular, this means that matplotlib.rc_params() will return the internal defaults rather than the one loaded from matplotlib_fname(). In practice this is not a problem because you can just use rc_file_defaults() (which caches a copy of the dict) instead.

Probably all these rc_* functions should also be cleaned up too...

This makes (e.g.)
```
$ MATPLOTLIBRC=<(echo 'savefig.transparent: true') python foo.py
```
use `savefig.transparent: true` as contents of matplotlibrc for the
given process (on POSIX).

This generalizes the MPLBACKEND mechanism to all rcParams (although the
lack of "cascading" rc-files means that the "normal" rc-file is
completely hidden).
@anntzer
Copy link
Contributor Author

anntzer commented Jan 15, 2018

Added some (minimal) docs (as stated above it seems pointless to explain what process substitution is in the mpl docs).
Not release critical by any means but seems trivial enough to keep for 2.2...

@efiring
Copy link
Member

efiring commented Jan 16, 2018

Looks harmless.

@efiring efiring merged commit b67098b into matplotlib:master Jan 16, 2018
@anntzer anntzer deleted the mplrc branch January 16, 2018 08:10
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
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.

MPLRC environment variable to set rcparams
4 participants