graph_objects

Anonymous contributor's avatar
Anonymous contributor
Published Jun 18, 2024
Contribute to Docs

In Python, the graph_objects module in Plotly is used for creating and manipulating complex plots and visualizations. It provides a structured way to build a wide variety of plot types using a declarative syntax. The core components of Plotly’s graph_objects module are:

  1. Figure: Represent the entire visualization, including data, layout, and styling.
  2. Traces: Define individual data sets and their properties (like markers, lines, etc.) within the figure.
  3. Layout: Control the overall appearance and arrangement of the visualization, including axes, titles, annotations, and more.

Key Features

  • Object-Oriented Approach: Allows for detailed customization and fine-grained control over plot attributes.
  • Composability: Different plot types and layout elements can be composed together to create intricate and layered visualizations.
  • Interactivity: Plots created with graph_objects are interactive, allowing for features such as zooming, panning, and tooltips.
  • Integration: Works seamlessly with various data sources and can be integrated into web applications using frameworks like Dash.

Applications

  • Creating 3D trace types like mesh or isosurface.
  • Generating subplots of different types and dual-axis plots.
  • Faceting plots with multiple different types of traces.

Syntax

import plotly.graph_objects as go

The go is an alias commonly used to refer to the graph_objects module.

graph_objects

.Barpolar()
Creates a polar bar chart in Plotly.
.Candlestick()
Creates candlestick charts to visualize financial data, showing open, high, low, and close values over time.
.Carpet()
Creates carpet plots to visualize interactions between multiple variables in a two-dimensional plot.
.Contour()
Creates a contour plot, which represents 3D surface data in 2D using contour lines or filled color regions to show variations in value.
.Figure()
Creates and manipulates figures in Plotly.
.Funnelarea()
Creates a funnel area chart where section sizes are proportional to given values.
.Heatmap()
Creates a plot with data visualized as colored tiles.
.Histogram2d()
Generates a 2D histogram to show the distribution and relationship between two variables, with color intensity representing the frequency of data points.
.Histogram2dContour()
Creates 2D histograms with contours for visualizing density distributions in data.
.Mesh3d()
Creates a 3D mesh plot in Plotly using the graph_objects module.
.Ohlc()
Creates an OHLC (Open-High-Low-Close) chart, which is commonly used in financial analysis to represent stock price movements over time.
.Parcoords()
Creates a parallel coordinates plot representing multivariate data.
.Sankey()
Creates Sankey diagrams, which visualize flow between categories using nodes and links.
.Scatterpolar()
Creates a scatter plot on polar axes.
.Scatterternary()
Creates ternary scatter plots in Plotly to visualize data with three components that sum to a constant.
.Surface()
Creates a 3d plot using the `Surface` class of the `graph_objects` module in Plotly

All contributors

Contribute to Docs

Learn Python:Plotly on Codecademy