- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- 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 plot values with log scales on x and y axis or on a single axis in R?

We can plot numerical values in R with many scales and that includes log scale as well. Also, it is possible to plot the values with log scales on both the axes. In base R, the best way to do this is defining the axes values with decimal representation as shown in the below examples with well-defined log.

Consider the below vector −

## Example

set.seed(555) x<-sample(1:9,10,replace=TRUE) x

## Output

[1] 4 8 7 5 6 1 9 2 1 8

Creating plot of x with log scale on both, x and y axis −

## Example

plot(x,xlim=c(0.000001,10),ylim=c(0.000001,10),log="xy")

## Output

Creating plot of x with log scale on y axis only −

plot(x,xlim=c(0.000001,10),ylim=c(0.000001,10),log="y")

## Output

Creating plot of x with log scale on x axis only −

plot(x,xlim=c(0.000001,10),ylim=c(0.000001,10),log="x")

## Output

- Related Questions & Answers
- Create ggplot2 graph with reversed Y-axis and X-axis on top in R.
- How to represent all values of X-axis or Y-axis on the graph in R using ggplot2 package?
- How to create a plot in base R with dates sequence on X-axis?
- How to create a bar plot using ggplot2 with percentage on Y-axis in R?
- How to specify values on Y-axis in Python Matplotlib?
- How to create a barplot with gaps on Y-axis scale in R?
- How to display raise to the power on X-axis in base R plot?
- How to plot int to datetime on X-axis using Seaborn?
- Transform the element along with x-axis and y-axis with CSS
- How to plot the X-axis labels on the upper-side of the plot in R?
- Transform the element by using x-axis, y-axis, and z-axis with CSS3
- Show the origin axis (x,y) in Matplotlib plot
- How to create a plot with reversed Y-axis labels in base R?
- How to plot two Pandas time series on the same plot with legends and secondary Y-axis in Matplotlib?
- How to change the Y-axis values in a bar plot using ggplot2 in R?

Advertisements