Python Function to Generate Bar Chart

  • Share this:

Code introduction


Create a bar chart where the x parameter represents the categories on the x-axis and the y parameter represents the corresponding values.


Technology Stack : Plotly

Code Type : Bar Chart

Code Difficulty : Intermediate


                
                    
import plotly.graph_objects as go

def create_bar_chart(x, y):
    fig = go.Figure(data=[go.Bar(x=x, y=y)])

    fig.update_layout(title_text="Bar Chart", xaxis_title="Categories", yaxis_title="Values")

    fig.show()                
              
Tags: