How to: Make a Polar Plot in Python

Publicado em: 03 Setembro 2020
no canal de: HagesLab
17,988
171

Learn how to make a 2D contour plot in Python in polar coordinates.

Script can be found here: https://www.hageslab.com/Resources.ht...

Here we are using "Spyder" IDE with the numpy and matplotlib libraries

Script:

import numpy as np
import matplotlib.pylab as plt

def T(theta,a,b):
return a*np.sin(theta*b)

def R(r,c,d):
return c*np.cos(r*d)

rlist=np.arange(0,4.01,0.01) #Angstroms
thetalist=np.radians(np.arange(0,361,1)) #Radians
rmesh, thetamesh = np.meshgrid(rlist, thetalist) #Generate a mesh

a = 1.5
b = 2
c = 2
d = 1.6

FullFunction = T(thetamesh,a,b)*R(rmesh,c,d)
FullFunction2 = FullFunction**2*rlist**2

fig, ax = plt.subplots(dpi=120,subplot_kw=dict(projection='polar'))
ax.contourf(thetamesh, rmesh, FullFunction, 100, cmap='plasma')

fig, ax = plt.subplots(dpi=120,subplot_kw=dict(projection='polar'))
ax.contourf(thetamesh, rmesh, FullFunction2, 100, cmap='plasma')


Nesta página do site você pode assistir ao vídeo on-line How to: Make a Polar Plot in Python duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário HagesLab 03 Setembro 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 17,988 vezes e gostou 171 espectadores. Boa visualização!