Skip to content

Instantly share code, notes, and snippets.

@GabrielSGoncalves
Created August 20, 2020 14:55
Show Gist options
  • Save GabrielSGoncalves/9d66fdb4cc656fa309e03fbc1521065d to your computer and use it in GitHub Desktop.
Save GabrielSGoncalves/9d66fdb4cc656fa309e03fbc1521065d to your computer and use it in GitHub Desktop.
Create a multiplot scatters using Plotly, redefine axis values and ticks and also add values next to markers.
import plotly.graph_objects as go
from plotly.subplots import make_subplots
fig = make_subplots(rows=2, cols=1,)
fig.add_trace(
go.Scatter(
x=df_analysis.index,
y=df_analysis.fpd_by_amount,
mode="lines+markers+text",
textposition="bottom center",
text=df_analysis.fpd_by_amount,
name="Por faturas",
yaxis="y1",
xaxis="x1",
),
row=1,
col=1,
).add_trace(
go.Scatter(
x=df_analysis.index,
y=df_analysis.fpd_by_customers,
mode="lines+markers+text",
textposition="top center",
text=df_analysis.fpd_by_customers,
name="Por clientes",
yaxis="y1",
xaxis="x1",
),
row=1,
col=1,
).add_trace(
go.Scatter(
x=df_analysis.index,
y=df_analysis.number_null_cpfs,
mode="lines+markers+text",
textposition="top center",
text=df_analysis.number_null_cpfs,
name="Clientes com valores nulos",
yaxis="y2",
xaxis="x2",
),
row=2,
col=1,
).update_layout(
width=1200,
height=800,
title="Cálculo de FPD utilizando jdsk",
yaxis1=dict(range=[30, 45], dtick=2, ticksuffix="%", title="First Payment Default"),
xaxis1=dict(
tickmode="array",
tickvals=list(df_analysis.index),
ticktext=None
),
yaxis2=dict(
range=[0, 100], tick0=10, dtick=20, title="Número total clientes valor nulo"
),
xaxis2=dict(
tickmode="array",
title="Mês",
tickvals=list(df_analysis.index),
),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment