Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

matplotlib.pyplot.polar() in Python

  • Last Updated : 22 Apr, 2020

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.

matplotlib.pyplot.polar() Function:

 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. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

The polar() function in pyplot module of matplotlib library is used to make a polar plot.

Syntax: matplotlib.pyplot.polar(*args, **kwargs)



Parameters: This method does not accept any parameters.

Returns: This method does not returns any value.

Below examples illustrate the matplotlib.pyplot.polar() function in matplotlib.pyplot:

Example #1:




# Implementation of matplotlib function
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import numpy as np
   
from matplotlib.transforms import offset_copy
   
xs = np.arange(-2, 2)
ys = np.cos(xs**2)
plt.polar(xs, ys) 
   
plt.title('matplotlib.pyplot.polar() function Example',
                                    fontweight ="bold")
plt.show()

Output:

Example #2:




# Implementation of matplotlib function
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import numpy as np
  
from matplotlib.transforms import offset_copy
  
xs = np.arange(8)
ys = np.cos(xs**2)
  
fig = plt.figure(figsize =(5, 10))
ax = plt.subplot(1, 1, 1)
  
trans_offset = mtransforms.offset_copy(ax.transData, fig = fig,
                                       y = 6, units ='dots')
  
for x, y in zip(xs, ys):
    plt.polar(x, y, 'go')
    plt.text(x, y, '% d, % d' % (int(x), int(y)),
                       transform = trans_offset,
                  horizontalalignment ='center',
                    verticalalignment ='bottom')
      
plt.title('matplotlib.pyplot.polar() function Example'
                                    fontweight ="bold")
plt.show()

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!