R: adding axis titles to non ggplot objects

*爱你&永不变心* 提交于 2021-02-05 09:25:07

问题


I am working with the R programming language. Normally when I make plots, I am using the ggplot2 library and the aes() options can be used to label the x-axis and add a title. However this time, I the plots I am making are not ggplot2 objects, and therefore can not be labelled in the same way:

library(MASS)
library(plotly)

a = rnorm(100, 10, 10)

b = rnorm(100, 10, 5)

c = rnorm(100, 5, 10)

d = matrix(a, b, c)

parcoord(d[, c(3, 1, 2)], col = 1 + (0:149) %/% 50)

#error - this is also apparent because the ggplotly() command can not be used.
ggplotly(d)

Does anyone know how to add labels on the x-axis of this plot and some title? Can the ggplotly command be used here?

Thanks


回答1:


You can use title(), e.g.

library(MASS)

a = rnorm(100, 10, 10)
b = rnorm(100, 10, 5)
c = rnorm(100, 5, 10)
d = matrix(a, b, c)

parcoord(d[, c(3, 1, 2)], col = 1 + (0:149) %/% 50)
title(main = "Plot", xlab = "Variable", ylab = "Values")
axis(side = 2, at = seq(0, 5, 0.1),
     tick = TRUE, las = 1)



来源:https://stackoverflow.com/questions/65836431/r-adding-axis-titles-to-non-ggplot-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!