MichaelR
MichaelR

Reputation: 152

Add labels on X-axis

Simple question.

I'd like to add custom characters to label the X-axis in R Histogram.

As can be seen on the image belov, the only labeling for the units is 0,50,100 but I'd like to have 0,5,10,15,etc (or 0:5,5:10,10:15,15:20,etc written perpendicular to the axis)

Illustration of how I'd like it to be

Is there a variable I've overlooked in customizing the addition of labels or do i need to use another lib than Hist, perhaps ggplot2?

Upvotes: 0

Views: 152

Answers (1)

Pedro Rafael
Pedro Rafael

Reputation: 522

Replying to someone who might be making a histogram without using ggplot2:

set.seed(0)
hist(runif(250, 0, 100), cex.axis = 0.6, xaxt = "n",
     col = rgb(0,0, 0.8, 0.35), border = FALSE, xlab = "x", main = "")

myseq <- as.character(seq(0,100, by = 5))
axis(1, at = myseq, labels = myseq, cex.axis = 0.6)
title(main = "Using of the graphics package", xlab = "x")

Upvotes: 1

Related Questions