Label for "sum of" in histogram

Hi, is it possible to set a label for the “sum of” expression?

image

labels={'ano':'Ano','processo':'NÂș de Processos','sum of':'','instancia_desc':'InstĂąncia'}

Anyone? I really need to find a way to “translate” this.

Hi, maybe you could create a custom hovertemplate?

1 Like

Do you have a sample or link to documentation about hovertemplate?

Hi, here’s some link to give you an idea on how to get started:

https://plotly.com/python/hover-text-and-formatting/

If you get stuck further, please provide a minimal example so people can help you better.

There are some examples on this site by searching for hovertemplate:
one such example: https://community.plotly.com/t/hovertemplate-with-customdata-or-hover-data-of-variable-shape/67901/2

also there are some guides to be found when you search on custom hovertemplate on google:

etc.

1 Like

Oi, Pedro! VocĂȘ poderia compartilhar a sua solução?

Sim, Ă© utilizar uma substituição em “labels”:

    fig = px.bar(filtered_df, x='comarca', y='quantidade',barmode='group', color_discrete_sequence=px.colors.sequential.Blugrn, title='Acervo por Comarca - 15 maiores (total: '+str('{:.0f}'.format(filtered_df_t['quantidade'].sum()))+')', labels={'competencia':'CompetĂȘncias',**'quantidade':'NÂș de Processos','sum of':''**,'competĂȘncia':'CompetĂȘncia','comarca':'Comarca'}, text='quantidade')
    fig.update_xaxes(type='category')
    fig.update_yaxes(tickformat='.')
    fig.update_layout(yaxis_title="# Processos")
    fig.update_layout(legend_title_text='CompetĂȘncia')
    fig.update_layout(hoverlabel=dict(bgcolor="white", font_size=14))
    return fig

Se nĂŁo foi isso, foi mudar de histograma para barra

Eu resolvi mudando o histograma pra barra. Ao fazer isso, tenho que passar o valor da outra coluna. Essa coluna que vai aparecer no hover no lugar da função agregadora do histograma. Eu faço o tratamento do dataframe, geralmente um agrupamento, mudando o nome pra o que eu quero que apareca no hover. Gostaria de saber se tem como editar o hover diretamente quando se usa o histograma. Fazendo essa alteração nos labels (no meu caso: ‘count’: ’ ') não funciona. Nada acontece.