How to install Plotly on your machine in Python

Built on top of the Plotly.js library in JavaScript, the library allows users to create interactive web-based graphs and visualizations in Python. It supports several types of charts such as financial, statistical, geographic, scientific, etc. We can display the charts in Jupyter Notebooks, save and open them as HTML files, or build web applications using Plotly Dash. This library also offers a range of interactive tools in the form of a floating toolbar which we can use to interact with the graph.

Installation of Plotly

However, Plotly doesn’t come with Anaconda by default. To install on our machine, we can type the following statement in the command window.

pip install plotly

Online vs. Offline: Plotly

Plotly is more than just a plotting library, it’s also a service. To use it in the online mode, we need to create a user profile and account to store our plots. So, we’ll need to provide the login credentials before we can start generating plots. However, it’s free to use. When we create a plot, it is sending a request to their servers and in return, they send us the results in an HTML format.

Since the python module uses the Plotly.js library for rendering, parameters to the API are passed in dictionary formats. To access this API, we use the package in python. Once we have created the account and received a personal API key, we can start setting up Plotly with the set_credential_files() function as follows.

import plotly’YourAccountName’, api_key=’YourAPIKey’)

It also enables us to save graphs locally through Plotly offline mode. In this case, we use plotly.offline.plot() or plotly.offline.iplot() functions to either display the plots within the notebook or create HTML pages that we can save locally on the machine.

Read More: Running install for matplotlib … \ – Taking longer time than usual
How to change figure size in Plotly in Python

Leave a Reply

Your email address will not be published. Required fields are marked *