Dygraph with R - 如何使用axisLabelFormatter 作为标签的字符大小?

CDC*_*DCD 5 r dygraphs axis-labels

我是 R 中 Dygraph 的新手,我用它来绘制我的数据(使用 xts)。一切正常,运行良好。

但问题是:我不能axisLabelFormatter用于使标签变粗和变大。这怎么可能?

此外,我可以在图表周围添加一个框架(如 x 和 y 轴的黑线)?

此处的图像解释了我的 2 个问题:单击此处查看示例图像

下面是我正在尝试的代码:

library(shiny)
library(dygraphs)
library(xts)

#------Importation des données contenues dans un .csv------
setwd("C:/Users") #attention,on ne peut pas faire créer à R un dossier, il faut le créer via windows

#----Importation données de qualité d'eau
TabSMP=read.csv2(file="Analyse R/MC1_MC2_SMP.csv",sep=";",dec=".",na.strings = "#N/A")
TabSMPMC1=read.csv2(file="Analyse R/MC1_SMP.csv",sep=";",dec=".",na.strings = "#N/A")
TabSMPMC2=read.csv2(file="Analyse R/MC2_SMP.csv",sep=";",dec=".",na.strings = "#N/A")
TabMC1Manu=read.csv2(file="Analyse R/MC1_Manu.csv",sep=";",dec=".",na.strings = "#N/A")
TabMC2Manu=read.csv2(file="Analyse R/MC2_Manu.csv",sep=";",dec=".",na.strings = "#N/A")
TabMC3Manu=read.csv2(file="Analyse R/MC3_Manu.csv",sep=";",dec=".",na.strings = "#N/A")
TabMC4Manu=read.csv2(file="Analyse R/MC4_Manu.csv",sep=";",dec=".",na.strings = "#N/A")


#-----Attribution du format de date et heure à la colonne date/heure pour chaque tableau------
TabSMP$DateHeure=as.POSIXct(TabSMP$DateHeure,format="%d/%m/%Y %H:%M")
TabSMPMC1$DateHeure=as.POSIXct(TabSMP$DateHeure,format="%d/%m/%Y %H:%M")
TabSMPMC2$DateHeure=as.POSIXct(TabSMP$DateHeure,format="%d/%m/%Y %H:%M")
TabMC1Manu$DateHeure=as.POSIXct(TabMC1Manu$Date,format="%d/%m/%Y %H:%M")
TabMC2Manu$DateHeure=as.POSIXct(TabMC2Manu$Date,format="%d/%m/%Y %H:%M")
TabMC3Manu$DateHeure=as.POSIXct(TabMC3Manu$Date,format="%d/%m/%Y %H:%M")
TabMC4Manu$DateHeure=as.POSIXct(TabMC4Manu$Date,format="%d/%m/%Y %H:%M")
#TabB5Manu$DateHeure=as.POSIXct(TabB5Manu$Date,format="%d/%m/%Y %H:%M")
ls.str()# vérification des reconnaissances par R des caractères numériques, textes, dates...


TabSMPMC1_xts_Temp <- xts(TabSMP$MC1_Temp,order.by=TabSMP$DateHeure,frequency=365)
TabSMPMC2_xts_Temp <- xts(TabSMP$MC2_Temp,order.by=TabSMP$DateHeure,frequency=365)
TabMC3Manu_xts_Temp <- xts(TabMC3Manu$MC3_Temp,order.by=TabMC3Manu$DateHeure,frequency=365)
TabMC4Manu_xts_Temp <- xts(TabMC4Manu$MC4_Temp,order.by=TabMC4Manu$DateHeure,frequency = 365)

Temperature <- cbind(TabSMPMC1_xts_Temp,TabSMPMC2_xts_Temp,TabMC3Manu_xts_Temp,TabMC4Manu_xts_Temp)

dygraph(Temperature,main="Evolution de la tempértaure") %>%
        dyAxis("y", label = "°C ", valueRange = c(-1, 11)) %>%
        dySeries("..1",label="MC1_Temp",strokeWidth=1.75) %>%
        dySeries("..2",label="MC2_Temp",strokeWidth=1.75) %>%
        dySeries("..3",label="MC3_Temp",pointSize=2.5) %>%
        dySeries("..4",label="MC4_Temp",pointSize=2.5) %>%
        dyOptions(colors = c("blue","orange","pink","green")) %>%
        dyLegend(width=400) %>%
        dyEvent(DebutVidange, "Ouverture Vanne de Fond", labelLoc = "top") %>%
        dyEvent(FinVidange, "Fin Vidange", labelLoc = "top") %>%
        dyShading(from =DebutVidange, to =FinVidange, color = "#F0F9FF") %>%
        dyShading(from =DebutAssec, to =FinAssec, color = "#FFFFFF") %>%
        dyRangeSelector()
Run Code Online (Sandbox Code Playgroud)

小智 2

尝试这个:

\n\n
    dyAxis(\n      "y",\n      axisLabelFormatter = \'function(d){return d.toString().fontsize(4);}\', #     makes them bigger\n      axisLabelWidth = 70\n    ) %>%\nand change the fontsize(4) to other numbers. An for bold tage the line: axisLabelFormatter = \'function(d){return d.toString().fontsize(4).bold();}\',\nas:\n\n    dygraph(Temperature,main="Evolution de la temp\xc3\xa9rtaure") %>%\n        dyAxis("y", label = "\xc2\xb0C ", valueRange = c(-1, 11)) %>%\n        dySeries("..1",label="MC1_Temp",strokeWidth=1.75) %>%\n        dySeries("..2",label="MC2_Temp",strokeWidth=1.75) %>%\n        dySeries("..3",label="MC3_Temp",pointSize=2.5) %>%\n        dySeries("..4",label="MC4_Temp",pointSize=2.5) %>%\n        dyOptions(colors = c("blue","orange","pink","green")) %>%\n        dyLegend(width=400) %>%\n        dyEvent(DebutVidange, "Ouverture Vanne de Fond", labelLoc = "top") %>%\n        dyEvent(FinVidange, "Fin Vidange", labelLoc = "top") %>%\n        dyShading(from =DebutVidange, to =FinVidange, color = "#F0F9FF") %>%\n        dyShading(from =DebutAssec, to =FinAssec, color = "#FFFFFF") %>%\n    dyAxis(\n      "y",\n      axisLabelFormatter = \'function(d){return d.toString().fontsize(4);}\', # makes them bigger\n      axisLabelWidth = 70\n    ) %>%\n        dyRangeSelector()\n
Run Code Online (Sandbox Code Playgroud)\n