<jupyter_start><jupyter_text>Introduction: Plotting with PlotlyIn this notebook, we will take a look at using the plotly library for plotting in Python. This library allows us to quickly make great plots and add interactive elements to our figures.<jupyter_code># Standard data science libraries
import pandas as pd
import numpy as np
from scipy import stats
import featuretools as ft

# Visualization
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use('bmh')

# Options for pandas
pd.options.display.max_columns = 20

# Display all cell outputs
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all'

import plotly.plotly as py
import plotly.graph_objs as go

trace1 = go.Scatter(x=[1,2,3], y=[10,5,6], marker={'color': 'red', 'symbol': 104, 'size': 10}, 
                    mode="markers+lines",  text=["one","two","three"], name='1st Trace')
                                               
data=go.Data([trace1])
layout=go.Layout(title="First Plot", xaxis={'title':'x1'}, yaxis={'title':'x2'})
figure=go.Figure(data=data,layout=layout)
py.iplot(figure, filename='pyguide_1')
figure.update(dict(layout=dict(title='Plot update'), data=dict(marker=dict(color='blue'))))
py.iplot(figure, filename='pyguide_2')
x = pd.date_range(pd.datetime(2018, 3, 1), pd.datetime(2018, 12, 1))
y = np.random.randn(len(x))

trace1 = go.Scatter(x=x, y=y, marker={'color': 'red', 'symbol': 104, 'size': 10}, 
                    mode="markers+lines", name='1st Trace')
                                               
#data=go.Scatter([trace1])
layout=go.Layout(title="First Plot", xaxis={'title':'x1'}, yaxis={'title':'x2'})
figure=go.Figure(data=[trace1],
                 layout=layout)
py.iplot(figure, filename='pyguide_1')
line1 = go.Scatter(x=[pd.datetime(2018, 12, 1, 5, 30),
                   pd.datetime(2018, 12, 1, 5, 30)], 
                y = [0, 2], mode = 'lines')
x = pd.date_range(pd.datetime(2018, 12, 1, 2, 30), 
                  pd.datetime(2018, 12, 1, 14, 30),
                  freq = '15 min')
y = np.random.randn(len(x))

trace1 = go.Scatter(x=x, y=y, marker={'color': 'red', 'symbol': 104, 'size': 10}, 
                    mode="markers+lines", name='1st Trace')
                                               
#data=go.Scatter([trace1])
layout=go.Layout(title="First Plot with vertical line", xaxis={'title':'x1'}, yaxis={'title':'x2'})
figure=go.Figure(data=[trace1, line1],
                 layout=layout)
py.iplot(figure, filename='pyguide_1')
df = pd.read_csv('ESB_power.csv', parse_dates = ['measured_at'])
df.describe()
x = df['measured_at']
y = df['10726']

trace1 = go.Scatter(x=x, y=y, marker={'color': 'red', 'symbol': 104, 'size': 10}, 
                    mode="markers+lines", name='1st Trace')
                                               
#data=go.Scatter([trace1])
layout=go.Layout(title="First Plot with vertical line", xaxis={'title':'x1'}, yaxis={'title':'x2'})
figure=go.Figure(data=[trace1],
                 layout=layout)
py.iplot(figure, filename='pyguide_1')
pd.datetime(2017, 12, 6).date()
x = list(df.loc[df['measured_at'].dt.date == pd.datetime(2018, 3, 18).date(),
           'measured_at'])
y = list(df.loc[df['measured_at'].dt.date == pd.datetime(2018, 3, 18).date(),
       '10726'])

trace1 = go.Scatter(x=x, y=y, marker={'color': 'red', 'symbol': 104, 'size': 10}, 
                    mode="markers+lines", name='1st Trace')
                                               
#data=go.Scatter([trace1])
layout=go.Layout(title="First Plot with vertical line", xaxis={'title':'x1'}, yaxis={'title':'x2'})
figure=go.Figure(data=[trace1],
                 layout=layout)
py.iplot(figure, filename='pyguide_1')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17466666666666666, 'fraction_numerical': 0.042666666666666665, 'mean_word_length': 3.252834467120181, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '333523', 'license': 'MIT', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1220, 'n_words': 274, 'path': 'plotly/.ipynb_checkpoints/plotly-intro-checkpoint.ipynb', 'repo_name': 'stuartzong/Data-Analysis', 'size': '3750'}