ferrum.coord¶
Coordinate system classes that control how positional encodings map to the plot area.
Coordinate-system declarations for ferrum charts.
CoordFlip
dataclass
¶
CoordCartesian
dataclass
¶
Standard Cartesian coordinates with optional domain and clip overrides.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xlim
|
(float, float) | None
|
Explicit x-axis domain |
None
|
ylim
|
(float, float) | None
|
Explicit y-axis domain |
None
|
expand
|
bool
|
Add padding around the data extent (default |
True
|
clip
|
bool
|
Clip marks to the plot area (default |
True
|
Examples:
>>> fm.Chart(df).mark_point().encode(x="x", y="y").coord(
... fm.CoordCartesian(xlim=(0, 100))
... )
CoordFixed
dataclass
¶
Cartesian coordinates with a fixed aspect ratio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ratio
|
float
|
Width-to-height ratio of one data unit. |
1.0
|
xlim
|
(float, float) | None
|
Explicit x-axis domain. |
None
|
ylim
|
(float, float) | None
|
Explicit y-axis domain. |
None
|
expand
|
bool
|
Add padding around data extent (default |
True
|
clip
|
bool
|
Clip marks to plot area (default |
True
|
Examples:
CoordPolar
dataclass
¶
Polar coordinates for pie and radial charts.
The theta parameter names which encoding channel ("x" or "y")
is interpreted as the angular variable. The other channel is used as the
radial variable (for scatter-in-polar mode); omit it for pie/donut charts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta
|
('x', 'y')
|
Which encoding channel maps to the angle. |
"x"
|
start
|
float
|
Starting angle in radians (default |
0.0
|
direction
|
(1, -1)
|
|
1
|
inner_radius
|
float
|
Inner radius in pixels. |
0.0
|
outer_radius
|
float or None
|
Outer radius in pixels. |
None
|
pad_angle
|
float
|
Angular gap between adjacent slices in radians (default |
0.0
|
Examples:
Pie chart::
fm.Chart(df).mark_arc().encode(x="value", color="category").coord(
fm.CoordPolar(theta="x")
)
Donut with 60 px hole::
fm.Chart(df).mark_arc().encode(x="value", color="category").coord(
fm.CoordPolar(theta="x", inner_radius=60)
)