×

Introduction To Plotly in Python

Plotly Logo Python

The Plotly library is an interactive open-source library. Plotly makes data visualization and understanding simple and easy. Plotly is a high-level, declarative charting library that includes over 30 chart types, including scientific charts, 3D graphs, statistical charts, SVG maps, financial charts, and more.

Why do we need plotly when there is matplotlib, seaborn like libraries in python?

All these three libraries do the same task, which is to plot a graph or chart for data visualization. But the difference because of which the library Plotly stands out are:

  • Plotly has hover tool capabilities that allow you to detect any outliers or anomalies in a large number of data points. When you hover your mouse cursor over the graph plotted by plotly you get the every details about that particular point in the graph where your cursor is.
  • It is visually attractive that can be accepted by a wide range of audiences. Many themes are available in plotly to make your charts and graph more appealing.
  • It allows you for the endless customization of your graphs that makes your plot more meaningful and understandable for others.
  • 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.
  • Dash is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.
  • The plotly graphs are stored in Javascript Object Notation (JSON) data format so that they can be read using scripts of other programming languages such as R, Julia, MATLAB etc.
  • The plotly graphs can be exported in various formats such as PNG, SVG, PDF and HTML to your local machine.

Installation

Run the following command in your terminal to install Plotly using pip.

pip install plotly

if you are using Anaconda then run the following command in your terminal to install Plotly using conda.

conda install -c plotly plotly

Test Installation

Before we can start using Plotly, let’s test its installation with an easy command:

import plotly
print(plotly.__version__)
Output
Plotly Version 1

Conclusion

So, in this article, we have talked about – why to use over other visualization modules supported by Python and Plotly installation. Next, we will talk about various plots in Plotly such as Line Plot, Scatter Plot, etc…