西班牙数字刻度格式刻度与 plotly
Spanish number tickformatting ticks with plotly
我需要把“,”改成“.”在两个轴上。这应该是一个简单且可重现的示例:
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='Exports per province and popultion <br><sup>Bubble size depends on population',
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
然后,我将其导出到 html。
fig.write_html("stack.html")
最后一部分:“tickformat”允许我设置一个“,”分隔符,但我正在寻找一个“。”分隔器。
这是结果:
非常感谢您的帮助!
在导出图形之前的代码末尾,您可以添加以下行(分隔符的文档是 here):
## sets decimal and thousands: default in english locales is ".,"
fig.update_layout(separators=",.")
然后你得到小数点作为分隔符。
我需要把“,”改成“.”在两个轴上。这应该是一个简单且可重现的示例:
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='Exports per province and popultion <br><sup>Bubble size depends on population',
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
然后,我将其导出到 html。
fig.write_html("stack.html")
最后一部分:“tickformat”允许我设置一个“,”分隔符,但我正在寻找一个“。”分隔器。 这是结果:
非常感谢您的帮助!
在导出图形之前的代码末尾,您可以添加以下行(分隔符的文档是 here):
## sets decimal and thousands: default in english locales is ".,"
fig.update_layout(separators=",.")
然后你得到小数点作为分隔符。