简体   繁体   中英

Modifying the X-Axis in R

图片

I have plotted a signal sampled at 20Hz and length of signal is 3940 (197 seconds) I want to modify the x-axis such that instead of showing limits from 0-3940 it shows 0-197s

First you need to plot your data without x-axis then you can add a custom one. refer to this question If your data is named df you can use:

plot(1:nrow(df), xaxt = "n", xlab='Axis Title')
axis(1, at=1:10, labels=seq(0, 197, by=nrow(df)/198)

If instead you have a vector you should use:

plot(1:length(df), xaxt = "n", xlab='Axis Title')
axis(1, at=1:10, labels=seq(0, 197, by=length(df)/198)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM