<jupyter_start><jupyter_text>Plotly - Vertical Barchart stacked **Tags:** plotly chart verticalbarchart group dataviz  Input  Import libraries<jupyter_code>import naas
import plotly.graph_objects as go<jupyter_output><empty_output><jupyter_text>Variables<jupyter_code>title = "Sales Evolution (group)"

# Output paths
output_image = f"{title}.png"
output_html = f"{title}.html"<jupyter_output><empty_output><jupyter_text>Get data<jupyter_code>x_axis = [1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012]

y_axis_value1 = [219, 146, 112, 127, 124, 180, 236, 207, 236, 263, 350, 430, 474, 526, 488, 537, 500, 439]

y_axis_value2 = [16, 13, 10, 11, 28, 37, 43, 55, 56, 88, 105, 156, 270, 299, 340, 403, 549, 499]<jupyter_output><empty_output><jupyter_text>Model  Create Vertical Barchart stacked<jupyter_code>fig = go.Figure()

Value1 = "USA"
Value2 = "Rest of world"

fig.add_trace(go.Bar(x=x_axis,
                y= y_axis_value1,
                name= Value1,
                marker_color='#5ee290'
                ))
fig.add_trace(go.Bar(x=x_axis,
                y= y_axis_value2,
                name= Value2,
                marker_color='#3f3f3f'
                ))

#fig.update_layout( hovermode="x", title=title)

fig.update_layout(
    title=title ,
    plot_bgcolor="#ffffff",
    #width=800,
    height=500,
    xaxis_tickfont_size=14,
    yaxis=dict(
        title='USD (millions)',
        titlefont_size=16,
        tickfont_size=14,
    ),
    legend=dict(
        x=0,
        y=1.0,
        bgcolor='white',
        bordercolor='white'
    ),
    barmode='stack',
    bargap=0.1, # gap between bars of adjacent location coordinates.
    bargroupgap=0.1 # gap between bars of the same location coordinate.
)
fig.show()<jupyter_output><empty_output><jupyter_text>Output  Export in PNG and HTML<jupyter_code>fig.write_image(output_image, width=1200)
fig.write_html(output_html)<jupyter_output><empty_output><jupyter_text>Generate shareable assets<jupyter_code>link_image = naas.asset.add(output_image)
link_html = naas.asset.add(output_html, {"inline":True})<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12644742936544698, 'fraction_numerical': 0.09634089856415007, 'mean_word_length': 3.853932584269663, 'pattern_counts': {'":': 1, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '341652', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 979, 'n_tokens_neox': 779, 'n_words': 158, 'path': 'Plotly/Plotly_Vertical_Barchart_stacked.ipynb', 'repo_name': 'vivard/awesome-notebooks', 'size': '2159'}