How to get rid or alter default axis labels and/or titles in density plot?
Asked Answered
M

3

6

I would like to know, how can I alter "default" x label (or subtitle) in density plot in R. For example, I do not wand this text "N = ..., bandwidth = ..." to be on the plot (I do not know if it is x-label or subtitle, but it usually appears under x-axis).

Microbicide answered 24/4, 2012 at 7:46 Comment(1)
Which function do you use to produce the plot?Grandfather
P
12

You should just use the standard plotting arguments to change the labels:

plot(density(rnorm(10)), 
     xlab="X", #Change the x-axis label
     ylab="Density", #y-axis label
     main="A nice title")#Main title

See the plotting help page: ?plot and the documentation.

Pippy answered 24/4, 2012 at 7:56 Comment(1)
Yes, it works. I was trying with xlab = NULL, but it turned out that in this case plot() function used default labeling. With xlab = "" the label disappeared.Microbicide
R
4

To get rib of them, simply specify them as NA

plot(density(rnorm(10)), 
xlab=NA, #Change the x-axis label
ylab=NA, #y-axis label
main=NA) #Main title
Raylenerayless answered 15/3, 2015 at 20:29 Comment(0)
J
-2

in plot function put ann=FALSE or in separate par function

Jodee answered 30/5, 2016 at 9:20 Comment(3)
Could you expand on your answer a little bit? In it's current state, it's a little vague. Maybe put down example of how to apply it.Cockneyism
I am sorry for not getting back, as my account was inactive. Here it goes in plot function,include an argument ann=FALSE , or use par(ann=FALSE) separatlyJodee
Please edit your clarifications in the answer you gaveTrouble

© 2022 - 2024 — McMap. All rights reserved.