简体   繁体   中英

Plotly Draw line according to an equation

I would like to drow a line according to an equation, for example: y=2x+3.

Is there any way to do this in plotly javascript (or python) without having to sample the equation at different points?

No, it is not possible in the way you are asking for. plotly just visualizes some arrays of data and these arrays can be obtained in different ways: eg by querying some database or by calculating with equation. But if you want to use equation, you have to calculate appropriate x and y arrays (or x , y and z in case of 3D plots) and then send it to plotly .

Here is example in Python (Jupyter Notebook):

from plotly.offline import init_notebook_mode, iplot
import numpy as np
init_notebook_mode()

x = np.linspace(-2, 3)
iplot([{'x': x, 'y': x**2}])

抛物线

If this is inappropriate way to do this for you, I believe it worth to expand a question and explain why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM