我刚刚安装了最新的plotly
R
package
(devtools::install_github("ropensci/plotly")
)。
我试图为单个变量生成小提琴图,我想抑制x轴标签。
我试过了:
library(dplyr)
library(plotly)
df <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/violin_data.csv")
plot_ly(y =~ df$total_bill,type = 'violin',
box = list(visible = T),
meanline = list(visible = T)) %>%
layout(xaxis = list(title = ""),yaxis = list(title = "Total Bill",zeroline = F))
我尝试使用x0
参数,但无法获得没有x轴标签的小提琴。
有什么想法吗?
答案 0 :(得分:0)
以下是使用ggplot2
+ ggplotly
的示例:
library(dplyr)
library(plotly)
librart(ggplot2)
df <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/violin_data.csv")
# Generate a ggplot with a violin plot and a boxplot
vioplot <- ggplot(df, aes(x = "", y=total_bill)) +
geom_violin(fill = "blue", alpha = 0.3) +
geom_boxplot(fill = "blue", alpha = 0.3) +
xlab("") + ylab("Total bill")
# Render the ggplot as a plotly object using ggplotly()
ggplotly(vioplot)
P.S。我无法使用plot_ly()
重现您的情节。我收到错误“错误:跟踪类型必须是以下之一:...”。无论如何,我不是plot_ly()
方式的忠实粉丝。我总是先通过一个ggplot。