Вы можете использовать data URIs и встраивать графику:
library(base64enc)
# unique filename; you can specify tmpdir for the
# location where the png will be written
this_file <- tempfile("supercoolplot", fileext=".png")
# make a png
png(file=this_file <- tempfile("supercoolplot", fileext=".png"), width=200, height=200, bg="transparent")
plot(sample(1:10, 10, replace=TRUE)) # randomize plot
rect(1,5,3,7,col="white")
dev.off()
# show you the file
print(this_file)
# encode the png
encoded_png <- sprintf("<img src='data:image/png;base64,%s'/>", base64encode(this_file))
# optionally remove the offending file
# if you use the tmpdir option then you can prbly leave the
# file there and serve it up via the <img/> tag directly
# vs encode it below
unlink(this_file)
# see what we did (only showing part of the string)
substr(encoded_png, 1, 80)
## [1] "<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAD"
# prove it works (run this in your R Console/RStudio
htmltools::html_print(htmltools::HTML(encoded_png))
Как уже отмечалось, вы можете выводить PNG (или JPEG в вашем случае) к TempFile/реж и (необязательно) удалить, что когда сделано.
Спасибо, я могу сгенерировать график в браузере. Моя основная забота заключалась в том, что с его JSP, если 100 пользователей используют JSP, тогда значение для x и y изменится (на основе пользователей). Итак, если я сохраню сюжет в файле (myplot.png), он будет перезаписан другими данными пользователя. Итак, я искал способ не сохранять в файле и извлекать данные, а просто показывать в браузере «на лету». –
Ответ обновлен для более подробного использования. – hrbrmstr
Спасибо. Можно ли открыть его на одной вкладке, он открывается на новой вкладке. –