Skip to content

Instantly share code, notes, and snippets.

View lucharo's full-sized avatar
🪐

Luis Chaves Rodriguez lucharo

🪐
  • London
  • 12:49 (UTC +01:00)
View GitHub Profile
@lucharo
lucharo / fig_layout.py
Last active October 6, 2020 16:42
Populate plotly.graph_objects.Figure['layout']
fig['layout'] = go.Layout(
font = {'size' : 14},
plot_bgcolor = 'white',
xaxis = {'showline': True,
'visible': True,
'range': (0, data['Value'].max()),
'title_text': 'Production Quantity (tonnes)' # title of the x axis
},
yaxis = {'showline': False,
'visible': True, # to show the title
@lucharo
lucharo / fig_data.py
Last active October 6, 2020 16:41
Populate plotly.go.Figure['data']
#1 Assign color to each unique item
from random import sample
colors = {item: 'rgb({}, {}, {})'.format(*sample(range(256), 3)) for item in data['Item'].unique()}
data['color'] = data['Item'].map(colors)
#2 Slice data, select earliest date available
##2.1 Select earliest year available
frame1 = data[data['Year'] == data['Year'].min()]