- R Graphs Cookbook Second Edition
- Jaynal Abedin Hrishi V. Mittal
- 195字
- 2021-08-05 17:30:33
Formatting log axes
In scientific analysis, we often need to represent data on a logarithmic scale. In this recipe, we will see how we can do this easily in R.
Getting ready
All you need to try out in this recipe is to run R and type the recipe in the command prompt. You can also choose to save the recipe as a script so that you can use it again later on.
How to do it...
The simplest way to create an axis logarithmic is to use the log
argument in the plot()
command:
plot(10^c(1:5),log="y",type="b")

How it works...
The log argument takes character values, specifying which axes should be logarithmic: x
for the x-axis only, y
for the y-axis only, and xy
or yx
for both axes.
There's more...
We can also set scales to be logarithmic by setting the xlog
and ylog
arguments to TRUE
with the par()
command. This can be handy if we wish to have the same setting for multiple plots as par()
applies the settings to all subsequent plots on the same device.
Note that R will not create the plot if our data contains zero or negative values.
- 電腦軟硬件維修大全(實例精華版)
- 極簡Spring Cloud實戰
- 平衡掌控者:游戲數值經濟設計
- 單片機原理及應用系統設計
- Apple Motion 5 Cookbook
- 面向對象分析與設計(第3版)(修訂版)
- 筆記本電腦芯片級維修從入門到精通(圖解版)
- STM32自學筆記
- Building Machine Learning Systems with Python
- 微服務架構基礎(Spring Boot+Spring Cloud+Docker)
- 從企業級開發到云原生微服務:Spring Boot實戰
- 施耐德M241/251可編程序控制器應用技術
- Arduino案例實戰(卷Ⅳ)
- Nagios系統監控實踐(原書第2版)
- Machine Learning Projects for Mobile Applications