Skip to content

Instantly share code, notes, and snippets.

@samirak93
Last active March 3, 2018 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samirak93/eb23fd4417f9e238ad9ff00cfe39cb21 to your computer and use it in GitHub Desktop.
Save samirak93/eb23fd4417f9e238ad9ff00cfe39cb21 to your computer and use it in GitHub Desktop.
import plotly.plotly as py
import plotly.graph_objs as go
import plotly.offline as offline
offline.init_notebook_mode()
midpoint_trace = go.Scatter(
x=[0],
y=[0]
)
# outer boundary
outer_shape = {
'type': 'rect',
'x0': -52.5,
'y0': -34,
'x1': 52.5,
'y1': 34,
'line': {
'color': 'rgba(0,0,0,1)',
'width': 2
},
}
# left box
left_backboard_shape = {
'type': 'rect',
'x0': -52.5,
'y0': -9,
'x1': -47,
'y1': 9,
'line': {
'color': 'rgba(0,0,0,1)',
'width': 2
},
}
# right backboard
left_penalty_shape = {
'type': 'rect',
'x0': -52.5,
'y0': -20,
'x1': -36,
'y1': 20,
'line': {
'color': 'rgba(0,0,0,1)',
'width': 2
},
}
# left box
right_box = {
'type': 'rect',
'x0': 46,
'y0': -9,
'x1': 52.5,
'y1': 9,
'line': {
'color': 'rgba(0,0,0,1)',
'width': 2
},
}
# right backboard
right_penalty_shape = {
'type': 'rect',
'x0': 36,
'y0': -20,
'x1': 52.5,
'y1': 20,
'line': {
'color': 'rgba(0,0,0,1)',
'width': 2
},
}
#center circle
center_circle = {
'type': 'circle',
'x0': -9,
'y0': -9,
'x1': 9,
'y1': 9,
'line': {
'color': 'rgba(0,0,0,1)',
'width': 2
},
}
# left arc shape
left_arc_shape = {
'type': 'path',
'path': 'M -36,-7 Q -32,0 -36,7',
'line': {
'color': 'rgba(0,0,0,1)',
'width': 2
},
}
# right arc shape
right_arc_shape = {
'type': 'path',
'path': 'M 36,-7 Q 32,0 36,7',
'line': {
'color': 'rgba(0,0,0,1)',
'width': 2
},
}
#Center line
center_line={
'type': 'path',
'path': 'M 0,-34 Q 0,0 0,34',
'line': {
'color': 'rgba(0,0,0,1)',
'width': 2
},
}
# list containing all the shapes
_shapes = [
outer_shape,
left_backboard_shape,
left_penalty_shape,
right_box,
right_penalty_shape,
center_circle,
left_arc_shape,
right_arc_shape,
center_line
]
layout = go.Layout(
title='Football Pitch',
shapes=_shapes
)
fig = go.Figure(data=[midpoint_trace], layout=layout)
offline.plot(fig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment