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

Datetime64 fixes #816

Merged
merged 13 commits into from
Aug 18, 2016
Merged

Datetime64 fixes #816

merged 13 commits into from
Aug 18, 2016

Conversation

philippjfr
Copy link
Member

Matplotlib does not currently support plotting numpy datetime64 types directly. This PR adds a compatibility layer ensuring these types are converted appropriately for plotting in matplotlib.

@philippjfr philippjfr added type: bug Something isn't correct or isn't working tag: backend: mpl tag: component: plotting labels Aug 17, 2016
@@ -61,6 +63,14 @@ def get_data(self, element, ranges, style):
ys = element.dimension_values(1)
return (xs, ys), style, {}

def init_artists(self, ax, plot_args, plot_kwargs):
xs, ys = plot_args
if xs.dtype.kind == 'M':
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth adding a comment mentioning what the 'M' code means. I assume it is the numpy datetime64 type?

@jlstevens
Copy link
Contributor

Looks good. Ready to merge?

@philippjfr
Copy link
Member Author

Think there might be a few more places where datetime64 support can be improved. Will investigate a bit more.

@philippjfr
Copy link
Member Author

philippjfr commented Aug 18, 2016

I've now overhauled the PR again. The main changes here are that you can now register datetime formatters for datetime64 and datetime types, which means you can now do this:

%%opts Curve [xrotation=15 xticks=5]
import numpy as np
from datetime import date
import pandas as pd

start = date(2012, 1, 15)
end = date(2012, 1, 30)
hv.Dimension.type_formatters[np.datetime64] = '%m/%d'
hv.Curve((pd.date_range(start, end, freq='D'), np.random.rand(16)))

image

Additionally I fixed various bugs in xarray date range handling and made formatting of grid tick labels consistent with everything else. Ready to merge now, but there's a definite possibility tests will break due to Grid tick formatting changes.

@philippjfr
Copy link
Member Author

Ready to review, updated test data will pass shortly.

@@ -262,9 +262,6 @@ class GridPlot(CompositePlot):
show_legend = param.Boolean(default=False, doc="""
Legends add to much clutter in a grid and are disabled by default.""")

tick_format = param.String(default="%.2f", doc="""
Copy link
Contributor

@jlstevens jlstevens Aug 18, 2016

Choose a reason for hiding this comment

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

So this parameter is now deprecated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, yes, we have a system for tick formatting using Dimension.value_format and Dimension.type_formatters, so this is redundant. You think we need to go through a deprecation cycle for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

It will at least need to be mentioned in the CHANGELOG. Other than that I think it is fine.

@jlstevens
Copy link
Contributor

Looks good. I've made two comments and once you have addressed those, I am happy to merge.

@jlstevens jlstevens merged commit 2b5e4a0 into master Aug 18, 2016
@philippjfr philippjfr deleted the datetime64_fixes branch September 2, 2016 00:57
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tag: backend: mpl tag: component: plotting type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants