[英]How to change the font size of the tick labels in contour plot colorbar in R?
I am using plot_ly
to plot a contour plot.我正在使用
plot_ly
到 plot 轮廓 plot。 The code is as follows:代码如下:
X = c(1, 2, 3, 4, 5, 6)
Y = c(seq(from = 1, to = 17, by = 1))
Z = matrix(runif(17*6), ncol=17)
m <- list(colorbar=list(title = "hi"))
plot_ly(
x = X,
y = Y,
z = t(Z),
type = "contour",
opacity = 100,
fillcolor = "FALSE",
line = list(width = 1.5),
contours = list(showlabels = TRUE,
labelfont = list(size = fs, color = 'white')),
color = I('black')
) %>%
layout(xaxis = list(title = "X", titlefont = list(size = fs),
ticktext = c("9:00", "9:30", "10:00", "10:30", "11:00", "11:30"),
tickvals = c(1, 2, 3, 4, 5, 6),
tickmode = "array",
tickfont = list(size=fs)),
yaxis = list(title = "Y", titlefont = list(size = fs),
ticktext = c("0", "30", "60", "90", "120", "150", "180", "210", "240",
"270", "300", "330", "360", "390", "420", "450", "480"),
tickvals = c(1:17),
tickmode = "array",
tickfont = list(size=fs)))
The output I get is:我得到的 output 是:
How do I change the font size of the colorbar tick labels (encircled in red)?如何更改颜色条刻度标签的字体大小(以红色圈出)?
Just include colorbar=list(tickfont=list(size=25))
in your chart setup.只需在图表设置中包含
colorbar=list(tickfont=list(size=25))
。
I had some problems with your sample code, so this will have to do:我的示例代码有一些问题,所以必须这样做:
Plot: Plot:
Code:代码:
library(plotly)
library(tidyr)
library(dplyr)
p <- plot_ly(
x = c(-9, -6, -5, -3, -1),
y = c(0, 1, 4, 5, 7),
z = matrix(c(10, 10.625, 12.5, 15.625, 20, 5.625, 6.25, 8.125, 11.25, 15.625, 2.5, 3.125, 5, 8.125, 12.5, 0.625, 1.25, 3.125,
6.25, 10.625, 0, 0.625, 2.5, 5.625, 10), nrow = 5, ncol = 5),
type = "contour",
colorbar=list(tickfont=list(size=25, color='red')),
contours = list(
start = 0,
end = 8,
size = 2)
)
p
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.