我想绘制双轴图表,我想要以百分比格式显示辅助Y轴(vcr)。我尝试将列乘以100并将%作为ticksuffix,但因为数据的范围从20%到70%变化,Y轴标签没有清楚地显示我得到的输出如附图所示:
ay <- list(
tickfont = list(color = "black"),
overlaying = "y",
showtickprefix = "all",
ticksuffix = "%",
#range = c(20,70),
tickfix = "%",
dtick = 0.5,
side = "right"
)
a <- list(
title = ""
)
b <- list(
title = ""
)
m = list(
l = 50,
r = 50,
b = 25,
t = 0,
pad = 4
)
p <- plot_ly(data = ctv_graph, x = impression_date, y = impressions , name = "Impressions",type="bar",marker = list(color = toRGB("#00C0EF"))) %>%
add_trace(x = impression_date, y = vcr, name = "VCR", yaxis = "y2") %>%config(displayModeBar=FALSE)%>%
layout(xaxis=a, yaxis=b, yaxis2 = ay, legend = list(x = 0, y = 1.15), margin = m)
})