R 旋转绘图条形图中的文字范围
有没有办法将文本标签在条上(R 旋转绘图条形图中的文字范围,r,plotly,R,Plotly,有没有办法将文本标签在条上(20,14,23)旋转90度 library(plotly) x <- c('Product A', 'Product B', 'Product C') y <- c(20, 14, 23) text <- c('27% market share', '24% market share', '19% market share') data <- data.frame(x, y, text) fig <- plot_ly(data, x
20,14,23
)旋转90度
library(plotly)
x <- c('Product A', 'Product B', 'Product C')
y <- c(20, 14, 23)
text <- c('27% market share', '24% market share', '19% market share')
data <- data.frame(x, y, text)
fig <- plot_ly(data, x = ~x, y = ~y, type = 'bar',
text = y, textposition = 'outside',
marker = list(color = 'rgb(158,202,225)',
line = list(color = 'rgb(8,48,107)', width = 1.5)))
fig <- fig %>% layout(title = "January 2013 Sales Report",
xaxis = list(title = ""),
yaxis = list(title = ""))
fig
library(plotly)
x您可以在plot\u ly
函数中使用textangle
参数
fig <- plot_ly(data, x = ~x, y = ~y, type = 'bar',
text = y, textposition = 'outside',
# rotate label
textangle = 90,
marker = list(color = 'rgb(158,202,225)',
line = list(color = 'rgb(8,48,107)', width = 1.5)))
fig <- fig %>% layout(title = "January 2013 Sales Report",
xaxis = list(title = ""),
yaxis = list(title = ""))
fig
图