Skip to content

Instantly share code, notes, and snippets.

@cereniyim
Created April 6, 2020 09:36
Show Gist options
  • Save cereniyim/e9470f9ebeb9cda18cba02909751a35d to your computer and use it in GitHub Desktop.
Save cereniyim/e9470f9ebeb9cda18cba02909751a35d to your computer and use it in GitHub Desktop.
explanation of how plotly works
import numpy as np
np.random.seed(42)
import plotly.offline as pyo
import plotly.graph_objs as go
# create data
x = np.random.randint(1, 101, 100)
y = np.random.randint(1, 101, 100)
# data object to be used in figure object
data = [go.Scatter(
x=x,
y=y,
mode='markers',
)]
# layout object to be used in figure object
layout = go.Layout(
title=’Plot title’,
xaxis=dict(title=’X-Axis’),
yaxis=dict(title=’Y-Axis’),
hovermode=’closest’
)
# figure object to display the plotly chart
fig = go.Figure(data=data, layout=layout)
pyo.plot(fig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment