vegas-viz / Vegas

The missing MatPlotLib for Scala + Spark
MIT License
730 stars 99 forks source link

Adjust axis maximum value #148

Closed KarakoA closed 5 years ago

KarakoA commented 5 years ago

Is it possible to set the maximum value of a axis? For example how can I set the maximum value of the X-Axis in the simple bar chart example presented in the notebook to 1000?

  withData(Seq(
    Map("a" -> "A", "b" -> 28), Map("a" -> "B", "b" -> 55), Map("a" -> "C", "b" -> 43),
    Map("a" -> "D", "b" -> 91), Map("a" -> "E", "b" -> 81), Map("a" -> "F", "b" -> 53),
    Map("a" -> "G", "b" -> 19), Map("a" -> "H", "b" -> 87), Map("a" -> "I", "b" -> 52)
  )).
  encodeX("a", Ordinal).
  encodeY("b", Quantitative).
  mark(Bar).
  show
oshikiri commented 5 years ago

@Tiatzi How about this?

Vegas().
  withData(Seq(
    Map("a" -> "A", "b" -> 28), Map("a" -> "B", "b" -> 55), Map("a" -> "C", "b" -> 43),
    Map("a" -> "D", "b" -> 91), Map("a" -> "E", "b" -> 81), Map("a" -> "F", "b" -> 53),
    Map("a" -> "G", "b" -> 19), Map("a" -> "H", "b" -> 87), Map("a" -> "I", "b" -> 52)
  )).
  encodeX("a", Ordinal).
  encodeY("b", Quantitative, scale = Scale(domainValues = List(0.0, 1000.0))).
  mark(Bar).
  show

image

(Is my understanding of this correct?)

KarakoA commented 5 years ago

Thank you very much! This is exactly what I was looking for.