Saturday, February 18, 2017

Bar plot in Python using Plotly

Step 1: Install plotly package if you haven't.

Follow this article:

Step 2: Set up your online credentials for plotly account.

2.1: Go to
2.2: Sign in/sign up.
2.3: Open (API Settings page) and click on Regenerate Key button. Copy the API key.

Step 3: Run the following command from Python.

import plotly'DemoAccount', api_key='lr1c37zw81')

Replace username and api_key with your values.

Step 4: Try the following program.

import plotly.plotly as py
import plotly.graph_objs as go

data = [go.Bar(
            x=['giraffes', 'orangutans', 'monkeys'],
            y=[20, 14, 23]

py.iplot(data, filename='basic-bar')

Step 5: Run and see output.

Step 6: View your plot from plotly portal and share it with others.

Hover on your plot and click on view.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.