How to create matrix of rgb values from a plot object

FWIW, this seems to do the same thing but avoids saving a file to disk:

using FileIO, Plots; gr()
p = plot(sin)
io_buf = IOBuffer()
show(io_buf, MIME("image/png"), p)
# io_buf.data

myImage = load(io_buf)  # Array{RGB{N0f8},2} with eltype RGB{N0f8}
plot(myImage, axis=nothing)
2 Likes