Skip to content

Latest commit

 

History

History
129 lines (100 loc) · 4.03 KB

File metadata and controls

129 lines (100 loc) · 4.03 KB
jupyter
jupytext kernelspec plotly
notebook_metadata_filter text_representation
all
extension format_name format_version jupytext_version
.md
markdown
1.1
1.1.1
display_name language name
Python 2
python
python2
description display_as has_thumbnail language layout name order page_type permalink thumbnail
Learn how to plot statistical data with various charts using Python.
statistics
false
python
base
Statistics Charts
5
example_index
python/statistics-charts/
/images/static-image

New to Plotly?

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!

Imports

The tutorial below imports NumPy, Pandas, and SciPy.

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

Import Data

For this example we will use some real data of wind speeds sampled every 10 minutes.

wind_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/wind_speed_laurel_nebraska.csv')
df = wind_data[0:10]

table = FF.create_table(df)
py.iplot(table, filename='wind-data-sample')

Histogram

We will be producing a histogram with the "10 Min Std Dev" column of our data. For more info on the histogram charts, you can checkout the documentation page.

data = [
    go.Histogram(
        x=wind_data['10 Min Std Dev'],
        histnorm='probability'
    )
]
py.iplot(data, filename='wind-data-histogram')

Box Plots

We will be producing a box plot with the "10 Min Std Dev" column of our data again. For more info on the histogram charts, you can checkout the documentation page.

data = [
    go.Box(
        y=wind_data['10 Min Std Dev'],
    )
]

py.iplot(data, filename='wind-data-box-plot')

Scatterplot Matrix (SPLOM)

We will be producing a scatterplot matrix chart, also known as a SPLOM chart, with all the columns of our data. For more info on SPLOM traces, you can checkout the documentation page.

fig = go.Figure(data=go.Splom(
    dimensions=[
        dict(label=col, values=wind_data[col]) for col in wind_data.columns
    ]
))

fig.update_layout(
    title='Wind Data - Scatterplot Matrix',
    height=1000,
    width=1000,
)
py.iplot(fig, filename='wind-data-scatterplot-matrix')
from IPython.display import display, HTML

display(HTML('<link href="proxy.php?url=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DOpen%2BSans%3A600%2C400%2C300%2C200%7CInconsolata%7CUbuntu%2BMono%3A400%2C700" rel="stylesheet" type="text/css" />'))
display(HTML('<link rel="stylesheet" type="text/css" href="proxy.php?url=http%3A%2F%2Fhelp.plot.ly%2Fdocumentation%2Fall_static%2Fcss%2Fipython-notebook-custom.css">'))

! pip install git+https://github.com/plotly/publisher.git --upgrade
import publisher
publisher.publish(
    'python-Statistics-Charts.ipynb', 'python/statistics-charts/', 'Statistics Charts | plotly',
    'Learn how to plot statistical data with various charts using Python.',
    title='Statistics Charts in Python. | plotly',
    name='Statistics Charts',
    language='python',
    page_type='example_index', has_thumbnail='false', display_as='statistics', order=5,
    ipynb= '~notebook_demo/116')