R+JAVA 產生圖片儲存圖片

來源:互聯網
上載者:User

標籤:span   語言   結束   tail   ble   div   engine   http   詳情   

// 初始化R解析類Rengine engine = new Rengine(null, false, null);/** * 美國整個曆史上的人口數量,繪圖 */// 年份double[] year = new double[] { 1790, 1800, 1810, 1820, 1830, 1840, 1850, 1860, 1870, 1880, 1890, 1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000 };// 人口數(單位:10萬)double[] people = new double[] { 39, 53, 72, 96, 128, 170, 231, 314, 385, 501, 629, 762, 922, 1060, 1232, 1421, 1613, 1893, 2133, 2365, 2587, 2914 };// 將數組賦值給R中向量engine.assign("year",year);engine.assign("people",people);engine.eval("setwd(\"D://RCharts\")"); // 圖表儲存路徑long chartName = System.currentTimeMillis(); // 時間戳記 engine.eval("png(file=\""+chartName+".png\", bg=\"transparent\")"); // 圖表儲存格式engine.eval("plot(year,people,type=\"h\")"); // 組建圖表engine.eval("dev.off()"); // 結束engine.stop();

 

可匯出的圖表格式

第一種png格式
png(file="myplot.png", bg="transparent")
dev.off()

第二種jpeg格式
jpeg(file="myplot.jpeg")
dev.off()

第三種pdf格式
pdf(file="myplot.pdf")
dev.off()

 

操作R語言圖形功能: bmp() -> plot() -> dev.off()

詳情:plot()與dev函數族的使用 (https://www.cnblogs.com/wangshenwen/archive/2013/07/28/3221808.html)

           R語言圖表基礎 (78447532)

R+JAVA 產生圖片儲存圖片

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.