Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase number of breaks on x axis in echarts4r plot?

I am making a simple histogram in echarts4r, but I am struggling to override the default x axis labels. For example in the plot below, I would like to have a label at every 3rd, instead of intervals of 5.

library(echarts4r)
  mtcars |>
    e_charts() |>
    e_histogram(mpg, name = "histogram",  breaks =seq(0,36,3)) 
like image 842
L Smeets Avatar asked Nov 16 '25 21:11

L Smeets


1 Answers

You could set the interval between ticks as well as the min and max values using e_x_axis like so:

See also the docs for more options.

library(echarts4r)
mtcars |>
  e_charts() |>
  e_histogram(mpg, name = "histogram",  breaks = seq(0,36,3)) |>
  e_x_axis(interval = 3, min = 3, max = 36)

enter image description here

like image 93
stefan Avatar answered Nov 18 '25 11:11

stefan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!