Skip to content

Annotations issues on distplots with plotly 3.1.0 #1084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rbgt opened this issue Jul 31, 2018 · 2 comments
Closed

Annotations issues on distplots with plotly 3.1.0 #1084

rbgt opened this issue Jul 31, 2018 · 2 comments

Comments

@rbgt
Copy link

rbgt commented Jul 31, 2018

Hello, I've had a new computer at work so I had to reinstall all packages and so on to get plotly and re-use my work I've done before,

I just noticed that when I wanted to add 1 notation, it did work, but when I wanted to add multiple notations (2 in my case), it didn't appear at all.

Here is how I did code in python 3:

fig_var=ff.create_distplot(data_var,labels,bin_size=0.00005,curve_type="normal",show_hist=True,show_rug=False)
fig_var['layout'].update(title='Distribution of potential loss/returns',
                         titlefont=dict(color='#FFF'),
                         legend=dict(
                                     font=dict(color='#FFF')),
                         plot_bgcolor='#000000',
                         paper_bgcolor='#000000',
                         xaxis=dict(title='Loss -- Returns (%)',
                                  titlefont=dict(color='#5998ff'),
                                  mirror='ticks',
                                  linecolor='#5998ff',
                                  linewidth=3,
                                  tickfont=dict(
                                                family='Old Standard TT, serif',
                                                color='white')
                                  ),
                         yaxis=dict(title='Number of minutes',
                                  titlefont=dict(color='#5998ff'),
                                  mirror='ticks',
                                  linecolor='#5998ff',
                                  linewidth=3,
                                  showticklabels=False
                                  ),
                         annotations=[
                                     dict(
                                          x=VaR_95,
                                          y=0,
                                          xref='x',
                                          yref='y',
                                          text='VaR 95',
                                          font=dict(color='#F00'),
                                          showarrow=True,
                                          arrowhead=7,
                                          ax=0,
                                          ay=-350,
                                          arrowcolor='#F00'
                                          ),
                                     dict(
                                          x=CVaR_95,
                                          y=0,
                                          xref='x',
                                          yref='y',
                                          text='Expected Shorfall',
                                          font=dict(color='#F00'),
                                          showarrow=True,
                                          arrowhead=7,
                                          ax=0,
                                          ay=-300,
                                          arrowcolor='#F00'
                                          )
                                 ]
                        )

in version 3.1.0, it didn't show any annotations and didn't mirror my blue lineborder either
whereas in version 2.7.0, it worked perfectly as expected.

Here is what I expect and working in plotly 2.7.0 :

expected

and here is the version 3.1.0 :

newversion

Does any of you has had an annotation issue related just like I did ? For another scatter plot, annotation worked but it seems not working for distplot here

Question: is there anything changed about annotations in the new version 3 plotly ?

NB: I didn't change the code in between the 2 versions, it was exactly the same.

Thank you for reading

@rbgt rbgt changed the title Annotations issues with plotly 3.1.0 Annotations issues on distplots with plotly 3.1.0 Jul 31, 2018
@jonmmease
Copy link
Contributor

jonmmease commented Jul 31, 2018

Hi @rickantonais , Thanks for taking the time to let us know. I believe this is a duplicate of #1072. In version 3 there's a problem using .update to initialize an array property (like layout.annotations).

Until a fix is out you can use property assignment to update the annotations. For example:

fig_var=ff.create_distplot(data_var,labels,bin_size=0.00005,curve_type="normal",show_hist=True,show_rug=False)
fig_var['layout'].update(title='Distribution of potential loss/returns',
                         titlefont=dict(color='#FFF'),
                         legend=dict(
                                     font=dict(color='#FFF')),
                         plot_bgcolor='#000000',
                         paper_bgcolor='#000000',
                         xaxis=dict(title='Loss -- Returns (%)',
                                  titlefont=dict(color='#5998ff'),
                                  mirror='ticks',
                                  linecolor='#5998ff',
                                  linewidth=3,
                                  tickfont=dict(
                                                family='Old Standard TT, serif',
                                                color='white')
                                  ),
                         yaxis=dict(title='Number of minutes',
                                  titlefont=dict(color='#5998ff'),
                                  mirror='ticks',
                                  linecolor='#5998ff',
                                  linewidth=3,
                                  showticklabels=False
                                  )
                        )

fig_var.layout.annotations=[
                                     dict(
                                          x=VaR_95,
                                          y=0,
                                          xref='x',
                                          yref='y',
                                          text='VaR 95',
                                          font=dict(color='#F00'),
                                          showarrow=True,
                                          arrowhead=7,
                                          ax=0,
                                          ay=-350,
                                          arrowcolor='#F00'
                                          ),
                                     dict(
                                          x=CVaR_95,
                                          y=0,
                                          xref='x',
                                          yref='y',
                                          text='Expected Shorfall',
                                          font=dict(color='#F00'),
                                          showarrow=True,
                                          arrowhead=7,
                                          ax=0,
                                          ay=-300,
                                          arrowcolor='#F00'
                                          )
                                 ]

Or you can downgrade back to version 2.7 and wait until a fix for #1072 is released (probably a couple of weeks).

Thanks!

@jorgeboucas
Copy link

jorgeboucas commented Oct 6, 2020

Hi, I am seeing this exact issue in plotly==4.5.0 and in 4.11. Any idea on when this will be fixed?

[ mpg-age-bioinformatics/flaski#120 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants