使用C3添加值时,Y轴标签消失

问题描述

如果我不尝试明确声明y轴的值,则C3图表将显示OK。但是,我发现标签很乱。

如果我尝试强制使用y轴标签值,则不会打印任何标签。

但是,第三个示例表明它们可以工作。

为什么它们在示例2中不起作用?

R脚本

library("c3")
library("tidyverse")

df <- structure(list(Date = structure(c(18503,18504,18505,18506,18507,18508,18509,18510,18511,18512,18513,18514,18515,18516,18517,18518,18519),class = "Date"),A = c(1.6,1.6,1.6),B = c(1.8,1.8,1.8),C = c(1.75,1.75,1.75),D = c(1.75,1.75
                                                                                                                                                            ),E = c(1.75,1.6)),row.names = c(NA,-17L),class = c("tbl_df","tbl","data.frame"))
# Example 1 ###############################
# Y-axis labels are there,but messy
df %>% 
  c3()

# Example 2 ###############################
# No Y-axis labels
df %>% 
  c3() %>% 
  tickAxis('y',values = c(0,1,2))

# Example 3 ###############################
# Clean Y-axis labels
data.frame(a = c(1,2,3,2),b = c(2,4,5)) %>%
  c3() %>%
  tickAxis('y',values = c(1,5))

解决方法

它实际上有效。您的min y轴值为1.58,而max1.8。由于您给出了c(0,1,2),因此放大后不会显示在图中。

尝试以下值,您将看到轴值。

df %>% 
  c3() %>% 
  tickAxis('y',values = c(1.6,1.65,1.7,1.8,1.81))

输出:

enter image description here

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...