在 R 中使用 Plotly 旋转标签
Rotate labels using Plotly in R
我正在尝试使用 Plotly 包将 xlab 垂直放置在绘图中。我想在标准 R 上执行与 "las= 2" 相同的操作。
我找到了 'tickangle = 45' 但它是用于刻度,而不是标签。
谁能帮帮我?
` plot_ly(x = account$country,
opacity = 0.6,
type = "histogram",
histnorm = "probability",
color = c('More than One account'),
colors = 'red') %>%
add_trace(x = account2$country,
opacity = 0.6,
type = "histogram",
histnorm = "probability",
color = c('Account'),
colors='blue') %>%
layout(barmode="overlay",
title = "Clients test",
xaxis = list(title = "Country", color ="red"),
yaxis = list(title = "Clients"))
`
谢谢。
对于您的情况,您可以在 xaxis 中添加 tickangle:
layout(barmode="overlay",
title = "Clients test",
xaxis = list(title = "Country", color ="red", tickangle = 90),
yaxis = list(title = "Clients"))
我正在尝试使用 Plotly 包将 xlab 垂直放置在绘图中。我想在标准 R 上执行与 "las= 2" 相同的操作。
我找到了 'tickangle = 45' 但它是用于刻度,而不是标签。
谁能帮帮我?
` plot_ly(x = account$country,
opacity = 0.6,
type = "histogram",
histnorm = "probability",
color = c('More than One account'),
colors = 'red') %>%
add_trace(x = account2$country,
opacity = 0.6,
type = "histogram",
histnorm = "probability",
color = c('Account'),
colors='blue') %>%
layout(barmode="overlay",
title = "Clients test",
xaxis = list(title = "Country", color ="red"),
yaxis = list(title = "Clients"))
`
谢谢。
对于您的情况,您可以在 xaxis 中添加 tickangle:
layout(barmode="overlay",
title = "Clients test",
xaxis = list(title = "Country", color ="red", tickangle = 90),
yaxis = list(title = "Clients"))