R 在绘图仪直方图中设置勾号格式';x轴
我有下面的简单数据框R 在绘图仪直方图中设置勾号格式';x轴,r,plotly,r-plotly,R,Plotly,R Plotly,我有下面的简单数据框d,我想根据其值的频率创建一个直方图。我试图将初始值设置为0,然后按5显示x轴上的值,但这两种方法似乎都不起作用,因为值从1开始,然后显示8。我希望在这方面有一个清晰的plotly解决方案作为首选,而不受ggplot()干扰 d<-data.frame(c(1,5,7,5,4,5,6,7,8,9,10,15,13)) x <- list( tick0=0, dtick=5 ) # Create the plotly histogram plot_ly
d
,我想根据其值的频率创建一个直方图。我试图将初始值设置为0
,然后按5
显示x轴上的值,但这两种方法似乎都不起作用,因为值从1
开始,然后显示8
。我希望在这方面有一个清晰的plotly解决方案作为首选,而不受ggplot()
干扰
d<-data.frame(c(1,5,7,5,4,5,6,7,8,9,10,15,13))
x <- list(
tick0=0,
dtick=5
)
# Create the plotly histogram
plot_ly(alpha = 0.9) %>%
add_histogram(x = as.factor(d[,1]),source="subset") %>%
# Add titles in plot and axes
layout(barmode = "overlay",xaxis=x,margin=list(b=100))
d%
#在绘图和坐标轴中添加标题
布局(barmode=“overlay”,xaxis=x,margin=list(b=100))
下面类似的方法有点不同,但我认为结果正是您想要的
d<-data.frame(x = c(1,5,7,5,4,5,6,7,8,9,10,15,13))
gg <- ggplot(d, aes(x)) + geom_histogram() + stat_bin(breaks = c(0, 5, 10, 15), binwidth = 5)
ggplotly(gg)
d感谢这很有用,可能会用到它,但如果存在,我更喜欢一个清晰的绘图解决方案