- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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 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 Articles
- How to represent all values of X-axis or Y-axis on the graph in R using ggplot2 package?
- Create ggplot2 graph with reversed Y-axis and X-axis on top in R.
- 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 plot on secondary Y-Axis with Python Plotly?
- How to display raise to the power on X-axis in base R plot?
- How to create a barplot with gaps on Y-axis scale in R?
- How to plot the X-axis labels on the upper-side of the plot in R?
- How to specify values on Y-axis in Python Matplotlib?
- How to create a plot with reversed Y-axis labels in base R?
- How to change the Y-axis values in a bar plot using ggplot2 in R?
- How to plot int to datetime on X-axis using Seaborn?
- How to display X-axis labels with dash in base R plot?
- How to create gridlines that matches with Y-axis values in the plot created by using plot function in R?
- How to plot two Pandas time series on the same plot with legends and secondary Y-axis in Matplotlib?

Advertisements