Getting Started with Plotly in Python
Plotly is a free and open-source graphing library for Python. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.
Overview¶
The plotly Python library is an interactive, open-source plotting library that supports over 40 unique chart types covering a wide range of statistical, financial, geographic, scientific, and 3-dimensional use-cases.
Built on top of the Plotly JavaScript library (plotly.js), plotly enables Python users to create beautiful interactive web-based visualizations that can be displayed in Jupyter notebooks, saved to standalone HTML files, or served as part of pure Python-built web applications using Dash. The plotly Python library is sometimes referred to as «plotly.py» to differentiate it from the JavaScript library.
Thanks to deep integration with our Kaleido image export utility, plotly also provides great support for non-web contexts including desktop editors (e.g. QtConsole, Spyder, PyCharm) and static document publishing (e.g. exporting notebooks to PDF with high-quality vector images).
This Getting Started guide explains how to install plotly and related optional pages. Once you’ve installed, you can use our documentation in three main ways:
- You jump right in to examples of how to make basic charts, statistical charts, scientific charts, financial charts, maps, and 3-dimensional charts.
- If you prefer to learn about the fundamentals of the library first, you can read about the structure of figures, how to create and update figures, how to display figures, how to theme figures with templates, how to export figures to various formats and about Plotly Express, the high-level API for doing all of the above.
- You can check out our exhaustive reference guides: the Python API reference or the Figure Reference
For information on using Python to build web applications containing plotly figures, see the Dash User Guide.
We also encourage you to join the Plotly Community Forum if you want help with anything related to plotly .
Installation¶
plotly may be installed using pip :
This package contains everything you need to write figures to standalone HTML files.
Note: No internet connection, account, or payment is required to use plotly.py. Prior to version 4, this library could operate in either an «online» or «offline» mode. The documentation tended to emphasize the online mode, where graphs get published to the Chart Studio web service. In version 4, all «online» functionality was removed from the plotly package and is now available as the separate, optional, chart-studio package (See below). plotly.py version 4 is «offline» only, and does not include any functionality for uploading figures or data to cloud services.
import plotly.express as px fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) fig.write_html('first_figure.html', auto_open=True)
Plotly charts in Dash¶
Dash is the best way to build analytical apps in Python using Plotly figures. To run the app below, run pip install dash , click «Download» to get the code and run python app.py .
Get started with the official Dash docs and learn how to effortlessly style & deploy apps like this with Dash Enterprise.
Sign up for Dash Club → Free cheat sheets plus updates from Chris Parmer and Adam Schroeder delivered to your inbox every two months. Includes tips and tricks, community apps, and deep dives into the Dash architecture. Join now.
JupyterLab Support¶
For use in JupyterLab, install the jupyterlab and ipywidgets packages using pip :
Creating and Updating Figures in Python
Plotly is a free and open-source graphing library for Python. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.
The plotly Python package exists to create, manipulate and render graphical figures (i.e. charts, plots, maps and diagrams) represented by data structures also referred to as figures. The rendering process uses the Plotly.js JavaScript library under the hood although Python developers using this module very rarely need to interact with the Javascript library directly, if ever. Figures can be represented in Python either as dicts or as instances of the plotly.graph_objects.Figure class, and are serialized as text in JavaScript Object Notation (JSON) before being passed to Plotly.js.
Note: the recommended entry-point into the plotly package is the high-level plotly.express module, also known as Plotly Express, which consists of Python functions which return fully-populated plotly.graph_objects.Figure objects. This page exists to document the structure of the data structure that these objects represent for users who wish to understand more about how to customize them, or assemble them from other plotly.graph_objects components.
Figures As Dictionaries¶
At a low level, figures can be represented as dictionaries and displayed using functions from the plotly.io module. The fig dictionary in the example below describes a figure. It contains a single bar trace and a title.
fig = dict( "data": ["type": "bar", "x": [1, 2, 3], "y": [1, 3, 2]>], "layout": "title": "text": "A Figure Specified By Python Dictionary">> >) # To display the figure defined by this dict, use the low-level plotly.io.show function import plotly.io as pio pio.show(fig)
Plotly Open Source Graphing Library for Python
Plotly’s Python graphing library makes interactive, publication-quality graphs. Examples of how to make line plots, scatter plots, area charts, bar charts, error bars, box plots, histograms, heatmaps, subplots, multiple-axes, polar charts, and bubble charts.
Plotly.py is free and open source and you can view the source, report issues or contribute on GitHub .
Deploy Python AI Dash apps on private Kubernetes clusters: Pricing | Demo | Overview | AI App Services
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial
View Tutorial