Skip to content
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

Merged
merged 1 commit into from
Jan 3, 2018

Conversation

jrleeman
Copy link
Contributor

@jrleeman jrleeman commented Jan 2, 2018

Closes #610 - Had to do some kwarg manipulation to keep the default black text when not in high contrast mode.

@jrleeman jrleeman added this to the 0.7 milestone Jan 2, 2018
@jrleeman jrleeman requested a review from dopplershift as a code owner January 2, 2018 20:20

Returns
-------
`matplotlib.text.Text`
The `matplotlib.text.Text` instance created

"""
if high_contrast:
text_args = {'color' : 'white'}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E203 whitespace before ':'

@jrleeman jrleeman force-pushed the path_effects branch 2 times, most recently from 708fa04 to dab774f Compare January 2, 2018 21:51
Copy link
Member

@dopplershift dopplershift left a 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.

@@ -6,6 +6,7 @@
from datetime import datetime
import posixpath

from matplotlib import patheffects
Copy link
Member

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

Copy link
Contributor Author

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


if high_contrast:
# Make the text stand out even better using matplotlib's path effects
outline_effect = [patheffects.withStroke(linewidth=2, foreground='black')]
Copy link
Member

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.

Copy link
Contributor Author

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.

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)
Copy link
Member

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(...)

@jrleeman
Copy link
Contributor Author

jrleeman commented Jan 3, 2018

This should be good to go now. Ping me when #692 is ready to go and I'll re-review and merge.

@dopplershift dopplershift merged commit 44178e9 into Unidata:master Jan 3, 2018
@jrleeman jrleeman deleted the path_effects branch January 3, 2018 21:13
@dopplershift dopplershift added Type: Enhancement Enhancement to existing functionality Area: Plots Pertains to producing plots labels May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Plots Pertains to producing plots Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants