-
Notifications
You must be signed in to change notification settings - Fork 422
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
Add high contrast functionality to timestamp #697
Conversation
metpy/plots/_util.py
Outdated
|
||
Returns | ||
------- | ||
`matplotlib.text.Text` | ||
The `matplotlib.text.Text` instance created | ||
|
||
""" | ||
if high_contrast: | ||
text_args = {'color' : 'white'} |
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.
E203 whitespace before ':'
708fa04
to
dab774f
Compare
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.
A couple minor things, can take them or leave them.
metpy/plots/_util.py
Outdated
@@ -6,6 +6,7 @@ | |||
from datetime import datetime | |||
import posixpath | |||
|
|||
from matplotlib import patheffects |
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.
We usually do this as:
import matplotlib.patheffects as mpatheffects
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.
Will change here, but in that case should probably change all the workshop material as well as it all uses the current method: https://github.com/Unidata/unidata-python-workshop/blob/master/notebooks/Satellite_Data/Working%20with%20Satellite%20Data.ipynb
metpy/plots/_util.py
Outdated
|
||
if high_contrast: | ||
# Make the text stand out even better using matplotlib's path effects | ||
outline_effect = [patheffects.withStroke(linewidth=2, foreground='black')] |
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.
Might be able to just include in text_args
as path_effects=[patheffects.withStroke(linewidth=2, foreground='black')]
.
That might simplify things a little.
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.
I like it as it'll let users specify custom path effects if they so desire.
metpy/plots/_util.py
Outdated
if not time: | ||
time = datetime.utcnow() | ||
timestr = datetime.strftime(time, 'Created: %Y-%m-%dT%H:%M:%SZ') | ||
return ax.text(x, y, timestr, ha=ha, transform=ax.transAxes, **kwargs) | ||
text = ax.text(x, y, timestr, ha=ha, transform=ax.transAxes, **text_args) |
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.
Any reason not to just do:
return ax.text(...)
This should be good to go now. Ping me when #692 is ready to go and I'll re-review and merge. |
Closes #610 - Had to do some kwarg manipulation to keep the default black text when not in high contrast mode.