Skip to content

feat(colorbar): support tick_labels, mirroring x_axis/y_axis #512

Description

@JuanCruzC97

xy.x_axis() / xy.y_axis() already accept tick_labels: Sequence[str] to pair with numeric tick_values, but xy.colorbar() only accepts numeric ticks: list[float] with no text-label equivalent.

We use xy.heatmap() to render a small set of discrete statuses (e.g. ok, expected_gap, unexpected_gap, unexpected_data) as banded colormap stops, following the pattern in docs/charts/heatmap.md's correlation-matrix example (xy.colorbar(title=..., ticks=[...])). The colorbar then shows the raw numeric band centers (e.g. 0.375, 1.125) instead of the status names — there's no way to label those ticks.

We understand xy.heatmap is intentionally continuous-only and that XY "deliberately emits no built-in colorbar for ... categorical color" per the colorbar docs — this isn't a request to make heatmap categorical. It's narrower: let xy.colorbar() take the same tick_labels parameter x_axis/y_axis already have, so a continuous scale with a small number of meaningful bands (like ours) can label its ticks instead of only showing positions.

Reproduction sketch:

import xy

chart = xy.heatmap_chart(
    xy.heatmap([[0, 1], [2, 3]], colormap="viridis", domain=(0, 3)),
    xy.colorbar(title="Status", ticks=[0.375, 1.125, 1.875, 2.625]),
)
# No way to render "ok" / "expected" / "unexpected" / "missing" at those
# tick positions -- xy.colorbar has no tick_labels param.

Environment: xy==0.0.6 (checked 0.0.7's changelog too -- not covered there).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions