Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions animatplot/animation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from matplotlib.animation import FuncAnimation, PillowWriter
from matplotlib.widgets import Button, Slider
import matplotlib.pyplot as plt
import numpy as np

from animatplot import Timeline


Expand Down Expand Up @@ -95,7 +97,7 @@ def pause(event):
self._pause ^= True
self.button.on_clicked(pause)

def timeline_slider(self, text='Time', ax=None, valfmt='%1.2f', color=None):
def timeline_slider(self, text='Time', ax=None, valfmt=None, color=None):
"""Creates a timeline slider.

Parameters
Expand All @@ -106,7 +108,7 @@ def timeline_slider(self, text='Time', ax=None, valfmt='%1.2f', color=None):
The matplotlib axes to attach the slider to.
valfmt : str, optional
a format specifier used to print the time
Defaults to '%1.2f'
Defaults to '%s' for datetime64, timedelta64 and '%1.2f' otherwise.
color :
The color of the slider.
"""
Expand All @@ -119,6 +121,13 @@ def timeline_slider(self, text='Time', ax=None, valfmt='%1.2f', color=None):
else:
self.slider_ax = ax

if valfmt is None:
if (np.issubdtype(self.timeline.t.dtype, np.datetime64)
or np.issubdtype(self.timeline.t.dtype, np.timedelta64)):
valfmt = '%s'
Comment thread
t-makaro marked this conversation as resolved.
else:
valfmt = '%1.2f'

if self.timeline.log:
valfmt = '$10^{%s}$' % valfmt

Expand Down