.create_bullet()
Published Feb 25, 2025
Contribute to Docs
.create_bullet()
is a function from the Plotly Figure Factory module that generates bullet charts. These charts compare a performance measure against predefined thresholds or ranges and are commonly used to visualize progress toward targets or key performance indicators (KPIs).
Syntax
plotly.figure_factory.create_bullet(
data,
markers=None,
measures=None,
ranges=None,
subtitles=None,
titles=None,
orientation='h',
width=None,
height=None,
**layout_options
)
Parameter | Description |
---|---|
data |
A list of dictionaries or a similar data structure describing chart parameters for each bullet. |
markers |
A list of target or reference values (for example, the goal). |
measures |
A list of actual values representing the performance metric being tracked. |
ranges |
A list of numeric intervals that define color-coded zones for context. |
subtitles |
A list of text labels for additional information or descriptions. |
titles |
A list of main titles or labels for each bullet. |
orientation |
Determines chart direction: 'h' (horizontal, default) or 'v' (vertical). |
width , height |
The figure’s width and height in pixels. |
**layout_options |
Additional layout attributes passed to the underlying Plotly figure (for example, margins, background color). |
Returns: A Plotly figure object that can be displayed or updated using standard Plotly methods.
Example
The example below demonstrates the usage of .create_bullet()
function:
import plotly.figure_factory as ffbullet_data = [{'title': 'Sales','subtitle': 'in thousands','ranges': [20, 30, 40],'measures': [22],'markers': [30]}]fig = ff.create_bullet(data=bullet_data,orientation='h',width=600,height=200)fig.update_layout(title="Bullet Chart Example")fig.show()
bullet_data
defines the ranges, measures, and markers for the bullet chart.create_bullet()
builds the chart with a chosen orientation and size.update_layout()
modifies the layout, including adding a title.fig.show()
displays the chart in an interactive environment such as Jupyter Notebook.
Here’s how the output will look like:
Contribute to Docs
- 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.
Learn Python:Plotly on Codecademy
- Career path
Data Scientist: Machine Learning Specialist
Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.Includes 27 CoursesWith Professional CertificationBeginner Friendly95 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours