Skip to content

datetime64 slider text support - #21

Merged
t-makaro merged 4 commits into
t-makaro:masterfrom
dcherian:fix/datetime64-slider-text
Feb 4, 2019
Merged

datetime64 slider text support#21
t-makaro merged 4 commits into
t-makaro:masterfrom
dcherian:fix/datetime64-slider-text

Conversation

@dcherian

@dcherian dcherian commented Nov 5, 2018

Copy link
Copy Markdown
Contributor

Closes #20

This makes it marginally better:
image

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

@t-makaro t-makaro left a comment

Copy link
Copy Markdown
Owner

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.

Comment thread animatplot/animation.py Outdated
@TomNicholas

Copy link
Copy Markdown
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

t-makaro commented Feb 1, 2019

Copy link
Copy Markdown
Owner

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

t-makaro commented Feb 3, 2019

Copy link
Copy Markdown
Owner

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
dcherian force-pushed the fix/datetime64-slider-text branch from 725a876 to f38d9d0 Compare February 4, 2019 16:31
@dcherian
dcherian force-pushed the fix/datetime64-slider-text branch from f38d9d0 to 9d3ee51 Compare February 4, 2019 16:32
@dcherian

dcherian commented Feb 4, 2019

Copy link
Copy Markdown
Contributor Author

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

Comment thread animatplot/animation.py
@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