在Dygraph R中调整图表区域

时间:2018-11-01 14:28:37

标签: r dygraphs r-dygraphs

我在Dygraphs R中制作了一个简单的图表,标题太长而无法放在一行上。例如:

library(tibble)
library(dygraphs)

dat <- tibble(x = 1:10, y = 11:20)

dygraph(dat, 
    main = "THIS TITLE HAS ONE LINE <br> THIS TITLE HAS TWO LINES <br> THIRD LINE")

Example graph here

第二行和第三行都出现在图表的业务中,图例使标题模糊不清。如何缩短图表区域以为主标题和图例腾出空间?

1 个答案:

答案 0 :(得分:0)

您应该在工作目录中创建dygraph.css文件,并在其中编写以下内容:

.dygraph-title {
background-color: white;
color:black;
text-align: left;
margin-left: 5%;
}

之后,将调用函数添加到主要函数中:

    library(tibble)
    library(dygraphs)

    dat <- tibble(x = 1:10, y = 11:20)

    dygraph(dat, 
        main = "THIS TITLE HAS ONE LINE <br> THIS TITLE HAS TWO LINES <br> THIRD LINE")%>%
        dyCSS("dygraph.css")