Plotly's Python library is free and open source! Get started by dowloading 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!
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.tools import FigureFactory as FF
import numpy as np
import pandas as pd
import scipy
Given two curves defined by functions $f$ and $g$ on $\mathbb{R} \rightarrow \mathbb{R}$, the average curve $h$ of $f$ and $g$ is defined by $h = \frac{f(x) + g(x)}{2} $ for $x \in \mathbb{R}$.
x = np.linspace(0, 2*np.pi, 100)
f = np.sin(x)
g = np.cos(x)
h = [(f[j] + g[j])/2 for j in range(len(x))]
trace1 = go.Scatter(
x=x,
y=f,
mode='lines',
name='f(x)',
marker=dict(
color='rgb(220, 20, 60)'
)
)
trace2 = go.Scatter(
x=x,
y=g,
mode='lines',
name='g(x)',
marker=dict(
color='rgb(100, 149, 237)'
)
)
trace3 = go.Scatter(
x=x,
y=h,
mode='markers+lines',
name='Average of f and g',
marker=dict(
color='rgb(128, 0, 128)',
symbol='diamond-open',
)
)
data = [trace1, trace2, trace3]
py.iplot(data, filename='2-curves')
from IPython.display import display, HTML
display(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">'))
! pip install git+https://github.com/plotly/publisher.git --upgrade
import publisher
publisher.publish(
'python_Average_Multiple_Curves.ipynb', 'python/average_multiple_curves/', 'Average Multiple Curves | plotly',
'Learn how to average the values of multiple curves with Python.',
title='Average Multiple Curves in Python | plotly',
name='Average Multiple Curves',
language='python',
page_type='example_index', has_thumbnail='false', display_as='mathematics', order=9,
ipynb= '~notebook_demo/107')
Collecting git+https://github.com/plotly/publisher.git Cloning https://github.com/plotly/publisher.git to /var/folders/ld/6cl3s_l50wd40tdjq2b03jxh0000gp/T/pip-CdzaoW-build Installing collected packages: publisher Found existing installation: publisher 0.10 Uninstalling publisher-0.10: Successfully uninstalled publisher-0.10 Running setup.py install for publisher ... - \ done Successfully installed publisher-0.10
/Users/brandendunbar/Desktop/test/venv/lib/python2.7/site-packages/IPython/nbconvert.py:13: ShimWarning: The `IPython.nbconvert` package has been deprecated. You should import from nbconvert instead. "You should import from nbconvert instead.", ShimWarning) /Users/brandendunbar/Desktop/test/venv/lib/python2.7/site-packages/publisher/publisher.py:53: UserWarning: Did you "Save" this notebook before running this command? Remember to save, always save. warnings.warn('Did you "Save" this notebook before running this command? '