eCharts 4 r-轴刻度/文本字体大小

zbdgwd5y  于 2023-03-05  发布在  Echarts
关注(0)|答案(1)|浏览(174)

是否可以更改y轴和x轴刻度的字体大小?
我已经浏览了文档,但找不到任何有效的东西。
复溶:

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)

7kjnsjlb

7kjnsjlb1#

一个选项是通过e_axis函数设置fontSize。正如我从文档中得到的,e_text_style设置了全局字体样式,但是似乎对刻度标签没有影响,除了第一个标签,其中显示的是年份而不是Jan。这个标签的字体大小必须通过e_text_style设置。不确定我是否错过了什么。

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  
  )

相关问题