- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- 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 create a scatterplot with log10 of dependent variable in R?

Most of the times, the relationship between independent variable and dependent variable is not linear. Therefore, we want to transform the dependent variable or independent variable based on our experiences. Hence, we also want to plot those transformations to visualize the relationship, one such transformation is taking log10 of the dependent variable. To plot this transformation of the dependent variable, we can use scale_y_continuous(trans='log10').

## Example

Consider the below data frame −

set.seed(10) x <-sample(1:50,20) y <-sample(1:5000,20) df <-data.frame(x,y)

Creating a scatterplot between x and y −

## Example

library(ggplot2) ggplot(df,aes(x,y))+geom_point()

## Output

Creating a scatterplot between x and log10 of y &minus

ggplot(df,aes(x,y))+geom_point()+scale_y_continuous(trans='log10')

## Output

- Related Articles
- Create scatterplot for two dependent variables and one independent variable in R.
- How to create a scatterplot between a variable and an equation in R?
- How to create a scatterplot using ggplot2 with different shape and color of points based on a variable in R?
- How to create a scatterplot with colors as group in R?
- How to create a scatterplot in R using ggplot2 with transparency of points?
- How to create a scatterplot with colors of the group of points in R?
- How to create a scatterplot with two legends using ggplot2 in R?
- How to create a scatterplot with dark points using ggplot2 in R?
- How to create a scatterplot with larger distance between facets in R?
- How to create a scatterplot in R using ggplot2 with different designs of points?
- How to create a scatterplot with low intensity of points using ggplot2 in R?
- How to create a scatterplot in base R with points depending on categorical column?
- How to create scatterplot with intercept equals to 1 using ggplot2 in R?
- How to create a boxplot with log of the variable in base R?
- How to create a scatterplot with white background and no gridlines using ggplot2 in R?

Advertisements