Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 旋转绘图条形图中的文字范围_R_Plotly - Fatal编程技术网

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