- 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.
- Cortex-M3 + μC/OS-II嵌入式系統開發入門與應用
- Linux KVM虛擬化架構實戰指南
- 施耐德SoMachine控制器應用及編程指南
- 精選單片機設計與制作30例(第2版)
- Svelte 3 Up and Running
- 計算機組裝與維修技術
- OUYA Game Development by Example
- 微服務分布式架構基礎與實戰:基于Spring Boot + Spring Cloud
- CC2530單片機技術與應用
- Spring Cloud微服務架構實戰
- OpenGL Game Development By Example
- 無蘋果不生活:OS X Mountain Lion 隨身寶典
- 數字媒體專業英語(第2版)
- RISC-V處理器與片上系統設計:基于FPGA與云平臺的實驗教程
- Hands-On Motion Graphics with Adobe After Effects CC