【发布时间】:2026-01-26 15:30:01
【问题描述】:
使用下面的代码,我可以创建图像中显示的图。我正在尝试解决以下一些问题:
1- 如何在标题和情节之间放置图例。我希望图例采用水平格式而不是当前的垂直格式。
2- 如何将情节标题加粗并居中?
3- 如何在 geom_point 函数中使用不同的形状,取决于“残疾”变量?
4- 如何重命名标签,使其显示为“死亡年龄”而不是当前名称:“AgeatDeath”?
谢谢,
纳德
IDD_line <-
ggplot(IDD_plot) +
geom_line(aes(x = Year, y = AgeatDeath, color = Disability), size = 1) +
geom_point(aes(x = Year,
y = AgeatDeath,
color = Disability),
size = 1.5,
shape = 21) +
scale_x_continuous(breaks = seq(2008, 2017, 1)) +
labs(
x = "Year",
y = "Age at Death",
caption = (""),
face = "bold"
) +
theme_bw() +
scale_y_continuous(breaks = seq(35, 80, 5)) +
ggtitle(paste("Age of Death by Year (2008 to 2017)")) +
theme(
legend.title = element_blank(),
axis.text = (blue.bold.10.text),
legend.position = "top"
)
output$IDD_plot <- renderPlotly(ggplotly(IDD_line) %>%
config(displayModeBar = F))
【问题讨论】:
标签: r shiny ggplotly geom-text