0

I'm plotting density graphs using the SM package in R. How do I adjust size of the numbers on the x and y axes? I've copied my code below. This should be a reproducible example if you have the SM package installed:

library(sm)

# sample data
stage <- c(1,2,3)
value <- c(4,5,6)

stage.f <- factor(stage, levels = c(1,2,3), labels = c("Phase 1", "Phase 2", "Phase 3") )
sm.density.compare(value, stage, xlab="value for ASC", 
    ylab="Density of value among respondents",
    h=0.3, lwd=3, lty=c(1,1,1), col=c("red","green","blue"))
title(main="value for ASC for the three phases")
colfill <- c(2:(2+length(levels(stage.f))))
legend("topright", levels(stage.f), fill=colfill)
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data so we can run and test the code. Make sure all variables are properly defined so the code is executable. – MrFlick Oct 31 '17 at 14:17
  • @MrFlick thanks for your tip. I've now amended the code. – anjahelsinki Oct 31 '17 at 15:56

1 Answers1

0

sm.density.compare uses base graphics to draw the plot. It doesn't seem to support passing plotting parameters directly to the function, but you can modify the default values before plotting. To increase the axis label size, use

par(cex.axis=2) # default value is 1

Try setting that value to something that works for you.

MrFlick
  • 195,160
  • 17
  • 277
  • 295