Wednesday, December 25, 2024
Google search engine
HomeLanguagesmatplotlib.pyplot.polar() in Python

matplotlib.pyplot.polar() in Python

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:

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:

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments