.bar()
Anonymous contributor
Anonymous contributor1 total contribution
Anonymous contributor
Published May 21, 2024
Contribute to Docs
In Plotly, the .bar()
method is part of the high-level interface named plotly.express
. It generates charts representing categorical data with vertical bars.
Syntax
plotly.express.bar(x, y, labels, title, width, height, ...)
x
: A string, integer, series, or array-like object designating the x-axis data.y
: A string, integer, series, or array-like object designating the y-axis data.labels
: A dictionary used for customizing labels, including column names, axis titles, hover labels, and legend entries.title
: A string designating the chart title.width
: An integer designating the chart width in pixels.height
: An integer designating the chart height in pixels.
Note: The ellipsis (…) indicates that there can be additional optional parameters beyond those listed here.
Example
Below is an example demonstrating how to use the .bar()
method to create a simple bar chart visualizing the values of items in categories a
, b
, c
, and d
:
import plotly.express as pxfig = px.bar(x=['a', 'b', 'c', 'd'], y=[1, 2, 3, 4], labels={'x':'Category', 'y':'Count'}, title='Simple Bar Chart', height=500, width=250)fig.show()
The above code produces the following output:
All contributors
- Anonymous contributorAnonymous contributor1 total contribution
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.