- Related Questions & Answers
- How to change the X-axis labels for boxplots created by using boxplot function in R?
- How to show all X-axis labels in a bar graph created by using barplot function in R?
- How to represent the mean with vertical line in a histogram created by hist function in R?
- How to reverse the X-axis labels of scatterplot created by using ggplot2 in R?
- How to create a dendrogram without X-axis labels in R?
- How to put labels on a scatterplot that is created plot function in R?
- How to add a mathematical expression in axis label in a plot created by using plot function in R?
- How to change the Y axis limit for boxplot created by using ggplot2 in R?
- How to change the gridlines of Y-axis on a chart created by using ggplot2 in R?
- How to change the color and size of the axes labels of a plot created by using plot function in R?
- How to display long X-axis labels in a bar chart using plotly in R?
- How to display mean inside boxplot created by using boxplot function in R?
- How to create gridlines that matches with Y-axis values in the plot created by using plot function in R?
- How to change ordinal X-axis label to text labels using ggplot2 in R?
- How to extract data from a plot created by ggplot2 in R?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

When we generate a histogram in R using hist function, the x-axis labels are automatically generated but we might want to change them to values defined by researchers or by any other authority. Therefore, firstly we need to create the histogram by ignoring the labels and then axis function can be used for new values.

Consider the below vector x and create a histogram of x by ignoring x-axis labels −

set.seed(1999) x<-rnorm(5000,9,1) hist(x,xaxt='n')

Now adding new values for x-axis labels −

axis(side=1,at=seq(6,12,1),labels=seq(6,12,1))

Advertisements