@openafox You cand define shapes in polar coordinates as filled closed curves. Below you find a function that defines the polar coordinates of the points on a circle of center (r0, theta0) and radius rho., as well as three shapes defined as go.Scatterpolar lines that define a filled close curve:
import plotly.graph_objects as go
import numpy as np
from numpy import pi, sin, cos, sqrt, arctan2
def circle(r0, theta0, rho, degrees = True):
# compute the polar coordinates for 100 points on a circle of center (r0, theta0) and radius rho
if degrees:
theta0 = theta0 * pi / 180
phi = np.linspace(0, 2*pi, 100)
x = rho * cos(phi) + r0 * cos(theta0)
y = rho * sin(phi) + r0 * sin(theta0)
r = sqrt(x**2 + y**2)
J = np.where(y<0)
theta = arctan2(y, x)
theta[J]= theta[J] + 2*pi
return (r, theta * 180 / pi) if degrees else (r, theta)
#define a general "shape"
fig = go.Figure(data = [go.Scatterpolar(
name = '',
r = [2, 3, 1, 4, 7, 5, 2, 2],
theta = [57, 229, 114, 85, 85, 343, 286, 57],
fill='toself',
mode='markers+lines',
marker_size=0.1)])
#define a curvilear rectangle
alpha = np.linspace(180,240, 60).tolist()
theta = alpha + alpha[::-1] + [alpha[0]]
fig.add_trace(go.Scatterpolar(r= [4]*60 + [6]*60+[4],
theta =theta,
name='',
fill='toself'))
#define a filled circle
r, theta = circle(4, 135, 1.5)
fig.add_trace(go.Scatterpolar(r=r, theta=theta,
mode='lines',
fill='toself',
name=''));
fig.update_layout(width=500, height=500, showlegend=False)
