Add text and line to an `image()` in graphics

前端 未结 1 1754
鱼传尺愫
鱼传尺愫 2021-01-05 15:11

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 tex

相关标签:
1条回答
  • 2021-01-05 15:24

    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)
    

    enter image description here

    0 讨论(0)
提交回复
热议问题