Skip to content

Interface with animation options in Plotly.js #1496

Closed
@TakodaS

Description

@TakodaS

Currently there is no option to access the animation options of Plotly.js from python. This makes it extremely difficult to make proper animations since the default time between frames in 500ms. I have added an extra keyword argument to offline.plot and offline.iplot called animation opts which allows the user to pass a python dictionary through and thus customize animations.

animation_opts (default=None) -- Custom animation parameters to be passed
    to the function Plotly.animate in Plotly.js in the form str(dict)
    Example:


from plotly.offline import plot
    figure = {'data': [{'x': [0, 1], 'y': [0, 1]}],
              'layout': {'xaxis': {'range': [0, 5], 'autorange': False},
                         'yaxis': {'range': [0, 5], 'autorange': False},
                         'title': 'Start Title'},
              'frames': [{'data': [{'x': [1, 2], 'y': [1, 2]}]},
                         {'data': [{'x': [1, 4], 'y': [1, 4]}]},
                         {'data': [{'x': [3, 4], 'y': [3, 4]}],
                          'layout': {'title': 'End Title'}}]}
    plot(figure,animation_opts="{frame: {duration: 1}}")

https://github.com/TakodaS/plotly.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions