Polar Charts using Plotly in Python

A Plotly is a Python library that 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.

Polar Charts in Plotly

These charts use a polar coordinate system, where its x-axis looks like a circle with the origin point as a center and each point is determined by distance from a fixed point and angle from a fixed direction. Polar charts are also known as radar charts, web charts, spider charts, and star charts, and many others. The radial and angular coordinates names are given as r and theta arguments.

Syntax: plotly.graph_objects.Scatterpolar(arg=None, cliponaxis=None,dr=None, dtheta=None,  line=None, marker=None,r=None, theta=None)

Parameters:

arg: dict of properties compatible with this constructor or an instance of plotly.graph_objects.Scatterpolar



r: Sets the radial coordinates

theta: Sets the radial coordinates

line: plotly.graph_objects.scatterpolar.Line instance or dict with compatible properties

marker: plotly.graph_objects.scatterpolar.Marker instance or dict with compatible properties

Example:

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

import plotly.graph_objects as go
  
fig = go.Figure(data=go.Scatterpolar(
    r=[1, 2, 3, 4, 5, 6, 7, 8, 9],
    theta=[69, 141, 213, 285, 357,
           429, 501, 573, 645],
    mode='markers',
))
  
fig.show()

chevron_right


Output:



Polar Bar Chart

In plotly, a polar bar chart can be created by using go.Barpolar() method of graph_object class. A polar bar chart is a chart that displays the data in the categorical form and the x-axis is in the circle and the origin is in the center.

Example:

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

import plotly.graph_objects as go
  
fig = go.Figure(data=go.Barpolar(
    r=[1, 2, 3, 4, 5, 6, 7, 8, 9],
    theta=[69, 141, 213, 285, 357,
           429, 501, 573, 645],
))
  
fig.show()

chevron_right


Output:

Line Polar Chart

In plotly, line polar charts can be made by using go.Scatterpolar() method of graph_object class. A line polar chart is a chart that displays data in series where the x-axis is in the circle and the origin is in the center. 

Example:

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

import plotly.graph_objects as go
  
fig = go.Figure(data=go.Scatterpolar(
    r=[1, 2, 3, 4, 5, 6, 7, 8, 9],
    theta=[69, 141, 213, 285, 357,
           429, 501, 573, 645],
    mode='lines',
))
  
fig.show()

chevron_right


Output:


Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.