Skip to content

Add scatter plot support (figure.scatter()) #1

Description

@MoonFlowww

Summary

Add a dedicated scatter() API to Figure that plots unconnected data points, matching matplotlib's plt.scatter() behavior.

Motivation

Scatter plots are the most common way to visualize raw performance samples — e.g., latency vs. throughput across different implementations. Currently users have to abuse plot() with line_style = LineStyle::None manually every time.

Proposed API

figure.scatter(x.data(), y.data(), n)
      .color(sepia::Color{255, 80, 80})
      .marker(sepia::MarkerStyle::Circle, 4.0)
      .label("impl A");

A scatter() call should default to:

  • line_style = LineStyle::None
  • marker = MarkerStyle::Circle
  • marker_size = 4.0

It should otherwise reuse PlotCommand and PlotEntry unchanged.

Implementation Notes

  • Add Figure::scatter(const double*, const double*, std::size_t) overload in include/sepia/plot2d/figure.hpp
  • Add a corresponding scatter(Series&&) and scatter_ref(...) overload for API symmetry with plot()
  • The implementation is ~5 lines: construct a PlotCommand with the two defaults pre-set
  • No changes needed to the rendering pipeline

Acceptance Criteria

  • scatter() compiles and renders correctly
  • Default marker/line defaults applied automatically
  • All three ownership models supported (scatter, scatter(Series&&), scatter_ref)
  • Example added to examples/scatter.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions