I frequently come up with an ideal visualization and then struggle to code it. It would be to the point, expressive, and easy to interpret, but it’s impossible to create. When I found Plotly it made plotting, well, much easier.
Plotly.Express, first introduced in version 4.0.0 is a high-level abstraction to Plotly API optimized to work perfectly with data frames. It’s very good, though not flawless. I see the biggest gap in the number of examples or links to the API documentation. That’s why I have decided to use my experience with the library to write a guide.
To run the chart and exercises, please use the Plotly Express — Comprehensive Guide.ipynb notebook on Github. All the code in this article is in python.
Table of contents:
Plotly.Express is a regular part of the Plotly python package, so the easiest is to install it all.
## pip
pip install plotly
## anaconda
conda install -c anaconda plotly
Plotly Express also requires pandas to be installed, otherwise, you will get this error when you try to import it.
[In]: import plotly.express as px
[Out]: ImportError: Plotly express requires pandas to be installed.
There are additional requirements if you want to use the plotly in Jupyter notebooks. For Jupyter Lab you need jupyterlab-plotly. In a regular notebook, I had to install nbformat
(conda install -c anaconda nbformat
)
#plotly #python #charts #plotly-express #visualization