- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change number formatting from scientific to numbers of axes labels in a scatterplot using ggplot2 package in R?
When we create a scatterplot or any other plot and the values are presented in scientific form in the original data then the axes values of the plot are also plotted in scientific form. This makes the plot ambiguous, therefore, reading the plot or interpreting it becomes difficult. Hence, we need to convert the scientific form of the axes labels to numbers and it can be done by using scale_x_continuous(labels =comma) and scale_y_continuous(labels=comma) for both the axes.
Consider the below data frame −
set.seed(101) x <-rpois(10,2)*100000 y <-rpois(10,5)*100000 df <-data.frame(x,y) library(ggplot2)
Creating the scatterplot −
Creating the scatterplot with numbers on axes −
ggplot(df,aes(x,y))+geom_point()+scale_x_continuous(labels = comma)+scale_y_continuous(labels=comma)
- How to change the axes labels using plot function in R?
- How to change the color of points in a scatterplot using ggplot2 in R?
- How to extract axes labels for the plot drawn using ggplot2 in R?
- How to reverse the X-axis labels of scatterplot created by using ggplot2 in R?
- How to change the default type of points for scatterplot using ggplot2 in R?
- How to display axes ticks and labels inside the plot using ggplot2 in R?
- Create a ggplot2 graph without axes labels, axes titles and ticks in R.
- R Programming how to display both axes’ labels of a ggplot2 graph in italics?
- Create a graph using ggplot2 without axes ticks and axes labels.
- How to change the color of points for ggplot2 scatterplot using color brewer in R?
- How to change ordinal X-axis label to text labels using ggplot2 in R?
- How to change the starting and ending points of axes labels using plot function in R?
- How to create a bar graph using ggplot2 without horizontal gridlines and Y-axes labels in R?
- How to increase the width of axes using ggplot2 in R?
- How to create a scatterplot in R using ggplot2 with transparency of points?