Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display logos on Plot.ly Bar figure

Tags:

python

plotly

I am currently doing a dataviz project, and I wish to add small images above each bar of my bar chart. For some reason, when I upload my own .png files, they can not be displayed.

When I use the .png files from the plot.ly documentation, it works fine. I produce it with the following:

new = go.Figure(data=[ 
    go.Bar(name = 'DC Men',
           x = dc_most_men.name,
           y = dc_most_men.appearances, 
           marker_color ='rgb(244,188,60)'),

    go.Bar(name = 'DC Females',
           x = dc_most_females.name,
           y = dc_most_females.appearances, 
           marker_color ='rgb(28,140,140)')
])

new.update_layout(
    xaxis=dict(
        showline=True,
        showgrid=False,
        showticklabels=True,
        linecolor='rgb(204, 204, 204)',
        linewidth=2,
        ticks='outside',
        tickfont=dict(
            family='Arial',
            size=12,
            color='rgb(82, 82, 82)',
        ),
    ),
    yaxis=dict(
        showgrid=False,
        zeroline=False,
        showline=False,
        showticklabels=True,
    ),

    autosize=False,
    margin=dict(
        autoexpand=False,
        l=100,
        r=20,
        t=110,
    ),
    showlegend=False,
    plot_bgcolor='white'

)
new.add_layout_image(
    dict(
        source='https://github.itu.dk/storage/user/2360/files/eeb40480-9c3b-11ea-99e6-b9ae4b500657',
        x=0.07,
        y=1,
    ))

new.add_layout_image(
    dict(
        source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/benzene.png",
        x=0.17,
        y=0.8,
    ))

new.add_layout_image(
    dict(
        source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/benzene.png",
        x=0.275,
        y=0.5,
    ))



new.update_layout_images(dict(
        xref="paper",
        yref="paper",
        sizex=0.1,
        sizey=0.1,
        xanchor="right",
        yanchor="bottom"
))

Which very nicely produces the following barchart: Image of the bar chart

However, when I upload my own files to GitHub, it seems to not display the logo at all. I made sure to change the path to the following link as well.

The link I use is: https://user-images.githubusercontent.com/47081217/82669721-3b97db00-9c3c-11ea-90f6-c525e647bc49.png

Is there anything I have over-looked?

like image 702
JOKKINATOR Avatar asked Nov 22 '25 15:11

JOKKINATOR


1 Answers

I don't think that from github could open an external link. Have you tried to download the png on the same folder where your notebook/script is?

like image 87
rpanai Avatar answered Nov 24 '25 04:11

rpanai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!