考虑以下示例:
data(canada.cities, package = "maps")
viz <- ggplot(canada.cities, aes(long, lat)) +
borders(regions = "canada") +
coord_equal() +
geom_point(aes(text = name, size = pop), colour = "red", alpha = 1/2) +
ggtitle(paste("Average bill for 1 people \n",
"Average bill for 2 people \n",
"Average bill for 3 people \n",
"Average bill for 4 people", sep = ""))
ggplotly(viz)
标题出现在一行中,这就是它被截止的原因。 我想要的是:
Average bill for 1 people
Average bill for 2 people
Average bill for 3 people
Average bill for 4 people
标题中的(4行)。
答案 0 :(得分:2)
在"<br>"
ggtitle
data(canada.cities, package = "maps")
viz <- ggplot(canada.cities, aes(long, lat)) +
borders(regions = "canada") +
coord_equal() +
geom_point(aes(text = name, size = pop), colour = "red", alpha = 1/2) +
ggtitle(paste("Average bill for 1 people \n",
"Average bill for 2 people \n",
"Average bill for 3 people \n",
"Average bill for 4 people", sep = "<br>"))
ggplotly(viz)