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 slider text support #21

Merged
merged 4 commits into from
Feb 4, 2019

Conversation

dcherian
Copy link
Contributor

@dcherian dcherian commented Nov 5, 2018

Closes #20

This makes it marginally better:
image

What do I need to do to make this much, much better ;)

Copy link
Owner

@t-makaro t-makaro left a comment

Choose a reason for hiding this comment

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

I'm not sure how I feel about special casing this, but if I user specifies a value for valfmt, then it should not be overridden.

animatplot/animation.py Outdated Show resolved Hide resolved
@TomNicholas
Copy link
Contributor

In xarray I made a special case which uses pandas.to_datetime() to format this as '2000-04-05 00:00:00', but the zeros still get hidden behind the play/pause button:

line1

I think the ideal general solution to this would mean the positioning of the play/pause button needs to be intelligent: it needs to take the length of the text string into account.

@t-makaro
Copy link
Owner

t-makaro commented Feb 1, 2019

It might be a good idea to move the default play/pause button location or make the automatic placement more intelligent, but I think that is beyond the scope of this PR.

@t-makaro
Copy link
Owner

t-makaro commented Feb 3, 2019

Is pd.to_datetime needed? When using np.datetime64 and valfmt='%s', the timeline slider formats just fine (in my tests). The datetime is displayed the smallest significant value.

import numpy as np
import animatplot as amp
import matplotlib.pyplot as plt

bimonthly_days = np.arange(0, 60)
base_date = np.datetime64('2017-01-01')
dates = base_date + bimonthly_days

t = np.linspace(0, 3, len(dates))
x = np.arange(0, 10, .2)

X, T = np.meshgrid(x, t)
Y = np.sin(X+T)

block = amp.blocks.Line(X, Y)
timeline = amp.Timeline(dates)

anim = amp.Animation([block], timeline)
anim.timeline_slider(valfmt='%s')

plt.show()

image

Obviously, the play/pause button overlapping is still an issue.

@dcherian
Copy link
Contributor Author

dcherian commented Feb 4, 2019

Made the changes. I'm not sure how to test it though.

animatplot/animation.py Show resolved Hide resolved
@t-makaro t-makaro merged commit df7070c into t-makaro:master Feb 4, 2019
@t-makaro t-makaro added this to the 0.4 milestone Feb 22, 2019
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.

3 participants