简体   繁体   English

如何使用R-Apache输出多个图形

[英]How do I output more than one graph using R-Apache

Below is my R code for graphing a function using quantmod, However the limit of this is that i can output only one graph. 以下是我的使用quantmod绘制函数图形的R代码,但是这样做的局限性是我只能输出一个图形。 Is there a way to have your function output more than one graph, Say by setting content to text/html and somehow rendering multiple graphs using that? 有没有一种方法可以让您的函数输出多个图形,比如说将内容设置为text/html并以某种方式呈现多个图形? Can you explain to me how to do that? 你能告诉我怎么做吗?

tickergraph = function()
{
setContentType ("image/png")
temp <- tempfile ()
png (temp, type="cairo")
ticker <- toupper(POST$t);
getSymbols(ticker)
chartSeries(eval(parse(text=ticker)))
dev.off ()
sendBin (readBin (temp, 'raw', n=file.info(temp)$size))
unlink (temp)
}

if(!is.null(POST$t))
{
tickergraph()
print(POST)
}

print("Cannot Plot when some of the values are NULL")

One way to solve this is to make a HTML-file that has all your graphs as img's such as: 解决此问题的一种方法是制作一个HTML文件,其中将所有图形作为img,例如:

<html><body>
<img src="firstgraph.r" /><br />
<img src="secondgraph.r" /><br />
…
</body></html>

then have firstgraph.r be something similar to the code you posted above (ie something that outputs image/png and secondgraph.r output another image/png with your second graph and so on. 然后让firstgraph.r与您上面发布的代码类似(即,输出image / png的东西和secondgraph.r与第二张图一起输出另一个image / png ,依此类推。

That will render a page which in turn loads all your images (which then will be generated on request). 那将呈现一个页面,该页面反过来加载您的所有图像(然后将根据请求生成)。

The other (more typical R-solution) would be to create a paneled graph, with all your graphs joined into one image (for instance through par(mfrows=c(2,1)) for a 2-by-1 graph). 另一个(更典型的R解决方案)是创建一个面板图形,将所有图形都合并到一个图像中(例如,通过par(mfrows = c(2,1)生成2×1图形)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Java Apache poi在Excel文件中插入多张图片? - How can I insert more than one picture in Excel file with Java Apache poi? 如何在R中为每个绘图代码生成多个文件格式? - How can I produce more than one file format per plot code in R? 如何命名包含多个索引的图像(使用pt.savefig)? - How can I name a image including more than one index (using pt.savefig)? Google AJAX API - 如何获得超过4个结果? - Google AJAX API - How do I get more than 4 Results? 如何使用imwrite在matlab中保存多张图像? - how to save more than one image in matlab using imwrite? 开放图谱协议:为什么要包含多个图像? - Open Graph Protocol: Reasons to include more than one image anyone? 如何在 laravel 中一次上传多个照片/文件? - How can i upload more than one photo / file at once in laravel? 如何使用多个外部图像作为缩略图在​​Facebook上共享URL - How to share an url on Facebook using more than one external image as thumbnails 如何使用swingworker重绘多个图像 - How to repaint more than one image with swingworker 如果我向库存项目上载了多个图像,如何将图像添加到Acumatica报告中? - How can i add an image to a Acumatica Report if i uploaded more than one image to a Stock Item?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM