stepped_histogram
Mojo function 🡭
stepped_histogram
fn def stepped_histogram(data: List[Float64], edges: List[Float64], weights: List[Float64] = List(), stat: HistStat = HistStat.COUNT, cumulative: Bool = False, 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, False, False, Color(UInt8(240), UInt8(240), UInt8(240), UInt8(255)), Int(3), 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)), ColorRamp(), ColorPalette(), SIMD(3), SIMD(15), True, SIMD(1), Int(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)), Color(UInt8(100), UInt8(100), UInt8(100), UInt8(255)), Color(UInt8(230), UInt8(230), UInt8(230), UInt8(255)), Color(UInt8(255), UInt8(255), UInt8(255), UInt8(255)), UInt8(90), UInt8(160), False, False, SIMD(0), SIMD(18), SIMD(14), Color(UInt8(110), UInt8(110), UInt8(110), UInt8(255)), SIMD(14), Color(UInt8(150), UInt8(150), UInt8(150), UInt8(255)), Color(UInt8(224), UInt8(236), UInt8(246), UInt8(200)), Color(UInt8(255), UInt8(255), UInt8(255), UInt8(255)), True, False, False, True, AxisPosition.EDGE, AxisPosition.EDGE, String("sans-serif"), True, UInt8(90), Int(5), Int(4), Int(130), Int(14), Int(8), Int(14), Int(100), Int(8), SIMD(4), OutputFormat.SVG, Tooltips.AUTO, Missing.DRAW, String("(missing)"), Int(1000), False, LineStyle.SOLID, SIMD(1.5), LineStyle.SOLID, LegendPosition.RIGHT, XAxisLabelRotation.AUTO, TickFormat.AUTO, TickFormat.AUTO), width: Int = Int(640), height: Int = Int(420), title: String = "", subtitle: String = "", x_title: String = "", y_title: String = "") -> Chart[Area]histogram() drawn as one filled staircase, Mark.AREA with StepStyle.POST, instead of separate bars: the bins as a single outline, the way a density estimate is read. Was histogram(..., stepfilled=True); a chart’s mark is its type, so a flag cannot choose it (#828). No horizontal form, since the staircase is an area.
Example:
from dataviz import stepped_histogram, save
def main() raises:
var data: List[Float64] = [1.0, 2.0, 2.5, 3.0, 3.2, 4.0, 5.5]
var edges: List[Float64] = [0.0, 2.0, 4.0, 6.0]
save(
stepped_histogram(data, edges, title="Bins as a staircase"),
"docs/src/examples/out_stepped_histogram.svg",
)Args:
- data (
List[Float64]): The raw values to bin. - edges (
List[Float64]): The bin edges, ascending, ashistogram()takes them. - weights (
List[Float64]): One nonnegative weight per observation, or empty. - stat (
HistStat): What each bin’s height means; seeHistStat. - cumulative (
Bool): Accumulate the bins left to right. - theme (
Theme): The theme. - width (
Int): Figure width in points. - height (
Int): Figure height in points. - title (
String): Chart title. - subtitle (
String): Chart subtitle. - x_title (
String): X-axis title. - y_title (
String): Y-axis title.
Returns:
Chart[Area]: The finished chart, unrendered.
Raises:
Error: data is empty, edges is malformed, or a value is
NaN/infinite.