Published on
September 3, 2020
Updated on
May 8, 2023
The graph below shows the quarterly evolution of prices per square meter, by “arrondissement” since 1996, based on data from the Notaires de Paris.
super-embed:
<iframe src="https://storage.googleapis.com/charlse/charlse/paris_estate.html" width="760" height="420"><iframe>
‣
# Plot evolution
## All arrondissements
fig = px.line(
df.loc[lambda x: x['Arrondissement'] != 'Paris'],
x='Quarter', y='Price', color='Arrondissement'
)
## Labels
for each_trace in fig.data:
each_trace['customdata'] = [each_trace['name']] * len(each_trace['x'])
fig.update_traces(
hovertemplate='<b>%{customdata}</b>: %{y:d} € <extra>%{x}</extra>',
showlegend=True,
line=dict(width=2, color='lightsteelblue'),
)
## Layout setup
fig.update_layout(
height=400, width=740,
margin=dict(l=60, r=0, b=20, t=0),
font=dict(family='Arial'),
xaxis={
'title': None,
'tickvals': list(range(0, len(df['Quarter'].unique()), 4)),
'ticktext': df['Year'].unique()
},
yaxis={
'title': None,
'tickformat': ':0d',
'ticksuffix': ' € '
},
showlegend=False
)
## Add colored line for Paris
fig.add_trace(go.Scattergl(
x=df.loc[lambda x: x['Arrondissement'] == 'Paris', 'Quarter'],
y=df.loc[lambda x: x['Arrondissement'] == 'Paris', 'Price'],
mode='lines', line=dict(width=3, color='firebrick'),
hovertemplate='<b>Paris</b>: %{y:d} € <extra>%{x}</extra>',
name='Paris'
))
# Display result
fig.show()