Skip to content

scale.zero option not useful for plotting negative numbers #933

@skybrian

Description

@skybrian

If I turn on the "zero" option for data that consists entirely of negative numbers, Plot doesn't choose a useful domain. In this case, the data contains values from -2 to -0.5, so a good domain including zero would be [-2, 0]. It seems to be picking something like [0, -0.5] instead, which is backwards and means that most points aren't plotted.

Plot.plot({
  width: width,
  height: 200,
  y: {zero: true},
  marks: [
    Plot.lineY([-1, -2, -0.5])],
});

Demo here.

A workaround is to set the domain manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn’t working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions