-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Adds metadata to help display matplotlib figures legibly #336
Adds metadata to help display matplotlib figures legibly #336
Conversation
Nice, thanks @telamonian! @minrk, it looks like tornado requires 3.4+ now, which is causing the CI failure. Any objections to switching this library to 3.4+ as well? |
EOL was last year: https://www.python.org/dev/peps/pep-0398/#x-end-of-life |
@blink1073 nope, go for it. Just make sure to update python_requires in setup.py |
Pushed the changes for 3.4+ |
Oh wait, I was thinking that we were keeping python 2.7 support, should we drop that as well? |
Let's not drop 2.7 just yet. So that would be the ever-so-convenient: python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', |
Ha! Clear as mud |
In she goes! |
Thanks @telamonian for working on this one!! This is great! We'll use it in Spyder too. |
Sweet! |
Very exciting to see this land, and glad it will get some use in multiple clients! |
That's great ! Definitively a huge plus for having organized sprint and community day. cc @rgbkrk for nteract support, and informing @tacaswell. |
for label in axis.get_ticklabels()]) | ||
if ticksLight.size and (ticksLight == ticksLight[0]).all(): | ||
# there are one or more tick labels, all with the same lightness | ||
return {'needs_background': 'dark' if ticksLight[0] else 'light'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
This is the sister PR of jupyterlab/jupyterlab#5232.
This PR adds some code so that when the matplotlib inline backend is enabled, one piece of extra metadata (
'needs-background'
) is passed along with each figure. This allows frontends to intelligently display a background behind the figure if it's needed to make the tick labels on the figure legible. This is implemented as so:Whenever the inline backend calls the
display(fig, metadata)
function,fig
is first checked to see if it has a transparent background. If it does, the color of each tick label in the figure is checked to see if it's light or dark. If all of the ticks are light, then'needs-background': 'light'
is added tometadata
, or if all are dark then'needs-background': 'dark'
is added. Otherwise, nothing is added tometadata
.See jupyterlab/jupyterlab#5232 for an example of an implementation of a frontend legibility fix using
'needs-background'
.