R:向非ggplot对象添加轴标题 [英] R: adding axis titles to non ggplot objects
本文介绍了R:向非ggplot对象添加轴标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 R 编程语言.通常,当我制作绘图时,我使用的是 ggplot2 库,并且 aes() 选项可用于标记 x 轴并添加标题.但是这一次,我制作的图不是 ggplot2 对象,因此不能以相同的方式标记:
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)
有谁知道如何在该图的 x 轴上添加标签和一些标题?这里可以使用ggplotly命令吗?
Does anyone know how to add labels on the x-axis of this plot and some title? Can the ggplotly command be used here?
谢谢
推荐答案
可以使用title()
,例如
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)
这篇关于R:向非ggplot对象添加轴标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文