polar_series
Mojo function 🡭
polar_series
fn def polar_series(angle: List[Float64], series_names: List[String], series_values: List[List[Float64]], theme: Theme = Theme(WHITE, Color(UInt8(30), UInt8(100), UInt8(180), UInt8(255)), Color(UInt8(80), UInt8(80), UInt8(80), UInt8(255)), Color(UInt8(225), UInt8(225), UInt8(225), UInt8(255)), Color(UInt8(40), UInt8(40), UInt8(40), UInt8(255)), SIMD(12), SIMD(3.5), SIMD(2), Int(60), Int(20), Int(20), Int(50), True, Color(UInt8(60), UInt8(110), UInt8(200), UInt8(255)), Color(UInt8(235), UInt8(235), UInt8(235), UInt8(255)), Color(UInt8(220), UInt8(90), UInt8(40), UInt8(255)), SIMD(3), SIMD(15), True, SIMD(1), SIMD(0), False, Color(UInt8(200), UInt8(60), UInt8(60), UInt8(255)), Color(UInt8(224), UInt8(224), UInt8(224), UInt8(255)), Color(UInt8(120), UInt8(120), UInt8(120), UInt8(255)), SIMD(0), SIMD(18), SIMD(14), Color(UInt8(110), UInt8(110), UInt8(110), UInt8(255)), SIMD(14), Color(UInt8(100), UInt8(100), UInt8(100), UInt8(255)), Color(UInt8(150), UInt8(150), UInt8(150), UInt8(255)), Color(UInt8(224), UInt8(236), UInt8(246), UInt8(200)), String("sans-serif"), True, SIMD(0.59999999999999998), SIMD(0.34999999999999998), SIMD(0.080000000000000002), Color(UInt8(230), UInt8(230), UInt8(230), UInt8(255)), Color(UInt8(255), UInt8(255), UInt8(255), UInt8(255)), UInt8(90), UInt8(90), SIMD(0.25), SIMD(0.40000000000000002), SIMD(0.41999999999999998), SIMD(0.69999999999999996), SIMD(0.90000000000000002), SIMD(1.3), SIMD(0.20000000000000001), Int(4), Int(12), Int(4), SIMD(2.3561944901923448), SIMD(4.7123889803846897), Int(5), Int(4), Int(130), Int(14), Int(8), Int(14), Int(100), Int(8), SIMD(12), OutputFormat.SVG), width: Int = Int(640), height: Int = Int(420), title: String = "", subtitle: String = "", x_title: String = "", y_title: String = "") -> PlotA multi-series polar-coordinate line plot – Mark.POLAR over Plot.encode_polar_series()’s shared angle domain plus one or more named series (series_names + series_values, one radius value per series per angle), sharing one radius scale across every series and a legend keyed by series_names. The same relationship pie()/donut() have to Mark.ARC – one mark, two quickplot entry points for two genuinely different shapes (here: one unlabeled trace vs. several compared side by side). See _render_ polar’s docstring for the full reasoning.
Example:
from std.math import pi
from dataviz_mojo import polar_series
from dataviz_mojo.plot import save
def main() raises:
var angle = List[Float64]()
for i in range(12):
angle.append(2.0 * pi * Float64(i) / 12.0)
var names: List[String] = ["Miami", "Phoenix"]
var miami: List[Float64] = [68.0, 69.0, 72.0, 76.0, 80.0, 83.0, 84.0, 85.0, 84.0, 80.0, 74.0, 69.0]
var phoenix: List[Float64] = [57.0, 61.0, 66.0, 75.0, 84.0, 95.0, 97.0, 95.0, 90.0, 78.0, 65.0, 56.0]
var values: List[List[Float64]] = [miami.copy(), phoenix.copy()]
var c = polar_series(angle, names, values)
save(c, "docs/src/examples/out_polar_series.svg")Args:
- angle (
List[Float64]): Radians, used exactly as given and unwrapped – shared by every series. - series_names (
List[String]): One trace per name, used as the legend key. - series_values (
List[List[Float64]]):series_values[j]isseries_names[j]’s radius per angle; every value must be non-negative, and every series shares one radius scale (max(radius)computed across all of them together). - theme (
Theme): Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – seeTheme’s docstring. - width (
Int): Pixel width of the returnedPlot(.size()). - height (
Int): Pixel height of the returnedPlot(.size()). - title (
String): The chart’s title, shown above the plot. - subtitle (
String): A secondary line shown under the title. - x_title (
String): The x-axis caption. - y_title (
String): The y-axis caption.
Returns:
Plot: The finished Plot – unrendered. Call save(plot, path) to write it (any of .svg/.png/.bmp), or render(plot)/render_svg(plot) for the explicit two-step.
Raises: