jupyter | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Plotly's Python library is free and open source! Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode, or in jupyter notebooks.
We also have a quick-reference cheatsheet (new!) to help you get started!
The tutorial below imports NumPy, Pandas, and SciPy.
importplotly.plotlyaspyimportplotly.graph_objsasgofromplotly.toolsimportFigureFactoryasFFimportnumpyasnpimportpandasaspdimportscipy
How to use numerical integration to find the area of
x=np.linspace(0, 2*np.pi, 100) y=np.sin(x) trace1=go.Scatter( x=x, y=y, mode='lines', ) # use numpy's built in trapezoid-rule integration tooldy=np.trapz(y, x) annotation=go.Annotation( x=4.5, y=1.25, text='Numerical Integration of sin(x) is approximately %s'% (dy), showarrow=False ) layout=go.Layout( annotations=[annotation] ) trace_data= [trace1] fig=go.Figure(data=trace_data, layout=layout) py.iplot(fig, filename='1d-numerical-integration')
fromIPython.displayimportdisplay, HTMLdisplay(HTML('<link href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Inconsolata|Ubuntu+Mono:400,700" rel="stylesheet" type="text/css" />')) display(HTML('<link rel="stylesheet" type="text/css" href="http://help.plot.ly/documentation/all_static/css/ipython-notebook-custom.css">')) ! pipinstallgit+https://github.com/plotly/publisher.git--upgradeimportpublisherpublisher.publish( 'python_Numerical_Integration.ipynb', 'python/numerical-integration/', 'Numerical Integration | plotly', 'Learn how to integrate a sequence or list of values numerically', title='Numerical Integration in Python. | plotly', name='Numerical Integration', language='python', page_type='example_index', has_thumbnail='false', display_as='mathematics', order=7, ipynb='~notebook_demo/101')