I generated an image in R from two-dimensional data - x
.
graphics::image(ifelse(drop(x)!=0, x, NA))
I would like to add a text and a line to the image.
I attempted text(10, 10, "testing")
and segments(5, 10, 20, 25)
, but neither the text nor the line was displayed.
As @MrFlick mentioned, image()
rescales values to the 0-1 range.
See below example:
#dummy data
set.seed(123)
x <- matrix(runif(100),nrow=10)
#plot
image(x)
#add text and a line
text(0.1,0.1,"text")
segments(0.5,0.1,0.2,0.25)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With