How to make ticks display more reasonably in BarX #2106
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
| Removing the  You could also set y interval to some high number but some of your data points would be rounded, i guess. Something like this: Plot.plot({
  y: { interval: 10 }
}); | 
Beta Was this translation helpful? Give feedback.
-
| For a continuous y axis (instead of categorical), use rect + bin instead of bar + group:  | 
Beta Was this translation helpful? Give feedback.
-
| To illustrate the options described by @Fil and @that-ambuj, here is what rect + bin would look like: Plot.plot({
  height: 500,
  x: {
    label: "← men · population (thousands) · women →",
    labelAnchor: "center",
    tickFormat: Math.abs
  },
  marks: [
    Plot.rectX(
      population,
      Plot.binY(
        { x: "sum" },
        {
          x: (d) => d.population * (d.sex === "M" ? -1 : 1),
          y: "age",
          fill: "sex",
          interval: 1
        }
      )
    )
  ]
})And here is what the interval option would look like (also using reverse to put zero at the bottom since ordinal y scales otherwise put the first value on top by default): Plot.plot({
  height: 500,
  x: {
    label: "← men · population (thousands) · women →",
    labelAnchor: "center",
    tickFormat: Math.abs
  },
  y: {
    interval: 1,
    reverse: true
  },
  marks: [
    Plot.barX(
      population,
      Plot.groupY(
        { x: "sum" },
        {
          x: (d) => d.population * (d.sex === "M" ? -1 : 1),
          y: "age",
          fill: "sex"
        }
      )
    )
  ]
}) | 
Beta Was this translation helpful? Give feedback.



To illustrate the options described by @Fil and @that-ambuj, here is what rect + bin would look like:
And here is what the interval option would look like (also using reverse to put zero at the bottom since ordinal y scales otherwise put the first value on top by default):