0

Is it possible to alter the font size of the y- and x-axis ticks?

I have looked through the documentation and can't find anything that works.

reprex:

library(lubridate)
library(echarts4r)

df <- data.frame(
  Date = dmy("01/01/2020","01/02/2020","01/03/2020","01/04/2020","01/06/2020"),
  Temperature = c(10, 2, 4, 5, 1),
  Phosphate = c(4, 1, 2, 5, 6)
)

df |> 
  e_charts(Date) |> 
  e_bar(Phosphate, y_index = 1) |>
  e_line(Temperature) |>
  e_text_style(fontSize = 24)

obrunt
  • 125
  • 7

1 Answers1

0

One option would be to set the fontSize via the e_axis functions. As I get it from the docs e_text_style sets the global font style, which however seems to have no effect on the tick labels except for the first label where instead of Jan the year is shown. The font size of this label has to be set via e_text_style. Not sure whether I missed something.

library(lubridate)
library(echarts4r)

df <- data.frame(
  Date = dmy("01/01/2020", "01/02/2020", "01/03/2020", "01/04/2020", "01/06/2020"),
  Temperature = c(10, 2, 4, 5, 1),
  Phosphate = c(4, 1, 2, 5, 6)
)

df |>
  e_charts(Date) |>
  e_bar(Phosphate, y_index = 1) |>
  e_line(Temperature) |>
  e_x_axis(
    axisLabel = list(
      fontSize = 24,
      color = "red"
    )
  ) |> 
  e_y_axis(
    axisLabel = list(
      fontSize = 24,
      color = "green"
    )
  ) |> 
  e_y_axis(
    index = 1,
    axisLabel = list(
      fontSize = 24,
      color = "blue"
    )
  ) |> 
  e_text_style(
    fontSize = 24  
  )

stefan
  • 90,330
  • 6
  • 25
  • 51
  • Great, thank you! Through your answer I found that the problem was happening when using a suffix. The fontSize won't apply when a suffix is being used, how weird. – obrunt Feb 24 '23 at 16:40