How to place arrows on the graph of a parametric curve - Python - Plotly

Asked

Viewed 208 times

1

I posted that same question earlier on stack overflow (in English).

I’m new in python and I’m learning to plot parametric functions using plotpy.

Therefore, I "challenged" myself to write a code that generates the parametric graph of the curve γ:[-2π,2π] R 2, γ(t)= (sin(t),t 2). So I wrote the following code:

import plotly as py
import plotly.graph_objs as go
import numpy as np

py.offline.init_notebook_mode(connected=True) 

x = np.linspace(-2*np.pi, 2*np.pi, 3000)

layout = go.Layout(
    title='$\gamma(t) = (\sin(t),t^2),\ t\in[-2\pi,2\pi]$',
    )

trace1= go.Scatter(
            x=np.sin(x),
            y=x**2,
            mode='lines',
            line=dict(
                shape='spline'
            )
        )

fig = go.Figure(data=[trace1],layout=layout)
py.offline.iplot(fig)


    

The code works and this is the output

Now, I would like to add some arrows in this graph in order to represent the direction of the path that the γ curve is taking. I mean, I’m trying to generate a similar image to this one:

enter image description here

I looked online about how to do this, but so far I found nothing.

Someone knows how to do it?

  • 1

    You can do without problems with Plotly using Multiple-Annotations, but it is not a simple code if you want the arrows to point in the direction of the curve, as it will be necessary to calculate the angle to which they point.

  • I’ll try to do, thank you for the comment

1 answer

1


Answering and not answering your question: you have to work with the tools that plotly gives you. Unfortunately this library does not support your requirement. I suggest you take a good look at the Plotly documentation and see if any other chart can meet your needs.

I hope I’ve helped!

  • Support matplotlib.pyblot, give a look

  • in matplotlib.pyplot I know how to do, I wanted to do using the ploply pq it is more "beautiful". Thanks for the reply

Browser other questions tagged

You are not signed in. Login or sign up in order to post.