出于某種原因,在使用該ggplotly函式生成繪圖時,過濾似乎不會調整 y 軸的大小。過濾后的部分被簡單地洗掉,而 yaxis 保持其原始長度。請看這個例子:
library(plotly)
library(ggplot2)
library(dplyr)
lab <- paste("Vertical Label", c(1, 2, 3, 4, 5))
ds <- data.frame(x = sample(lab, size = 1000, replace = T),
y = sample(LETTERS[1:5], size = 1000, replace = T)) %>%
group_by(x,y) %>% summarise(count= n())
ggplotly(
ggplot(ds, aes(x = x,y=count, fill = y))
geom_col()
theme(axis.text.x = element_text(angle = 90))
)

與plot_ly功能相同的方法有效。但是,我需要類似的結果ggploty
plot_ly(ds, x = ~x, y = ~count, type = 'bar', color = ~y
) %>% layout(title = "Vertical Axis Lables",
xaxis = list(title = ""),
yaxis = list(title = ""), barmode = 'stack')

我在堆疊溢位或谷歌中找不到任何有用的東西。剛剛在這里遇到了一個不完整的答案:
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/358877.html
標籤:r ggplot2 情节地 r-plotly ggplotly
下一篇:即使不在圖中也顯示圖例標記和標簽
