Formato de marcas numéricas con Plotly Tickformatting de números en español con Plotly
Necesito cambiar la “,” por un “.” en ambos ejes. Este debería ser un ejemplo fácil y reproducible:
import plotly.express as px
import pandas as pd
df = pd.DataFrame(
{"pop" : [1000000, 1500000, 2000000, 2500000, 4000000, 4500000],
"exports" : [26000000, 30000000, 35000000, 40000000, 45000000, 90000000],
"year" : [2018, 2018, 2019, 2019, 2020, 2020],
"prov": ['a', 'b', 'a', 'b', 'a', 'b']})
df
fig = px.scatter(
df, x="pop",
y="exports", animation_frame="year",
animation_group="prov",
size = "pop",
hover_name="prov",
log_x=True, size_max=50,
range_x=[900000,4600000],
range_y=[25000000,100000000],
title='Exportaciones por provincia y población <br><sup>El tamaño de las burbujas depende de la población',
template="simple_white"
)
fig.update_traces(textposition='top center')
fig.update_layout(
font = dict(
family="helvetica neueltstd",
size = 18
)
)
fig.update_yaxes(tickformat = ".")
fig.update_xaxes(tickformat = ".")
fig
Luego, lo exporto a html.
fig.write_html("stack.html")
La última parte: “tickformat” me permite establecer un separador “,”, pero estoy buscando un separador “.”.
Este es el resultado:
¡Cualquier ayuda es muy apreciada!
davy.ai
Para cambiar el separador de coma por un separador de punto en ambos ejes, simplemente actualiza el parámetro tickformat a ‘.’:
Aquí está el código completo:
Esto resultará en el siguiente gráfico:
“>Comments are closed.