Open In App

Plotting graphs using Python's plotly and cufflinks module

Last Updated : 04 Sep, 2024
Comments
Improve
Suggest changes
6 Likes
Like
Report

plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library.

cufflinks connects plotly with pandas to create graphs and charts of dataframes directly.

choropleth is used to describe geographical plotting of USA. choropleth is used in the plotting of world maps and many more. Let's plot different types of plots like boxplot, spreadplot, etc. using plotly and cufflinks.

Command to install plotly:

pip install cufflinks plotly                                                                                                                                            

Command to install cufflinks:

pip install plotly                                       

Code #1:

Show dataframe


Output:

dataframe2

Code #2:

Normal Plot

# plotly function
df.iplot()

Output:

graph

Code #3:

Scatter Plot

# markers are made to point in the graph
df.iplot(kind ='scatter', x ='A', y ='B', mode ='markers')

Output:

marker

Code #4:

Box Plot

# boxplot
df.iplot(kind ='box')

Output:

box

Code #5:

Plot dataframes

# creating dataframe with three axes
df3 = pd.DataFrame({'x':[1, 2, 3, 4, 5],
                    'y':[10, 20, 30, 20, 10],
                    'z':[5, 4, 3, 2, 1]})

Output:

dataframe

Code #6:

Surface plot

# surface plot
# colorscale:red(rd), yellow(yl), blue(bu)
df3.iplot(kind ='surface', colorscale ='rdylbu')

Output:

graph

Next Article
Article Tags :
Practice Tags :

Similar Reads