échantillon parcellaire
import
import plotly
import plotly.graph_objs as go
import pandas as pd
import numpy as np
df = pd.read_csv('https://raw.githubusercontent.com/jbrownlee/Datasets/master/daily-total-female-births.csv')
df['Births2'] = df['Births'] + np.random.normal(0, df['Births'].std(), [len(df)]).astype(int)
df['Births3'] = df['Births'] + np.random.normal(0, df['Births'].std() * 2, [len(df)]).astype(int)
df = df.loc[:50, :]
Liune Chart
tr1 = go.Scatter(x=df["Date"], y=df["Births"], mode="lines+markers")
layout = go.Layout(
title="Births",
xaxis=dict(title="date"),
yaxis=dict(title="births")
)
plotly.offline.iplot(dict(data=[tr1], layout=layout))
Save and show fig
plotly.offline.iplot(dict(data=[tr1], layout=layout), filename='result', image="png")
tr1 = go.Scatter(x=df["Date"], y=df["Births"], mode="lines+markers+text", text=df["Births"], textposition="top center")
layout = go.Layout(
title="Births",
xaxis=dict(title="date"),
yaxis=dict(title="births")
)
plotly.offline.iplot(dict(data=[tr1], layout=layout))
tr1 = go.Scatter(x=df["Date"], y=df["Births"], mode="lines+markers", name="Births")
tr2 = go.Scatter(x=df["Date"], y=df["Births2"], mode="lines+markers", name="Births2")
tr3 = go.Scatter(x=df["Date"], y=df["Births3"], mode="lines+markers", name="Births3")
layout = go.Layout(
title="Births",
xaxis=dict(title="date"),
yaxis=dict(title="births")
)
plotly.offline.iplot(dict(data=[tr1, tr2, tr3], layout=layout))
scatter
tr1 = go.Scatter(x=df["Date"], y=df["Births"], mode="markers")
layout = go.Layout(
title="Births",
xaxis=dict(title="date"),
yaxis=dict(title="births")
)
plotly.offline.iplot(dict(data=[tr1], layout=layout))
Histogram
tr1 = go.Histogram(x=df["Births"], xbins=dict(start=0, end=101, size=5))
layout = go.Layout(
title="Births",
xaxis=dict(title="birth"),
yaxis=dict(title="count"),
bargap=0.2
)
plotly.offline.iplot(dict(data=[tr1], layout=layout))
tr1 = go.Histogram(x=df["Births"], xbins=dict(start=0, end=101, size=5))
tr2 = go.Histogram(x=df["Births2"], xbins=dict(start=0, end=101, size=5))
layout = go.Layout(
title="Births",
xaxis=dict(title="birth"),
yaxis=dict(title="count"),
bargap=0.2,
bargroupgap=0.2
)
plotly.offline.iplot(dict(data=[tr1, tr2], layout=layout))
Recommended Posts