In [2]:
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
import pandas as pd
import os

Plotly Basics of Plotting

Importing Data

Let's start by importing our data using the methods described in the excelToPandas notebook.


In [8]:
dirPath = os.path.realpath('.')
fileName = 'assets/coolingExample.xlsx'
filePath = os.path.join(dirPath, fileName)
df = pd.read_excel(filePath,header=0)
cols = df.columns

Creating the plot

Plots in plotly are generated using the graph_objs object from the plotly library.

Additionally, the layout is declared in a dictionary with parameters title, xaxis, and yaxis, where xaxis and yaxis also are declared as dictionaries with one entry, title


In [7]:
# Create a trace
trace = go.Scatter(
    x = df[cols[0]],
    y = df[cols[1]]
)

data = [trace]

# Edit the layout
layout = dict(title='Temperature vs. Time',
              xaxis=dict(title='Time'),
              yaxis=dict(title='Temperature (C)'),
              )

fig = dict(data=data, layout=layout)
py.iplot(fig, filename='Thermal Data')


Out[7]: