首页 > 解决方案 > Display four lineChart() in different windows or simultaneously in R and ESS, quantmod

问题描述

How can I display these four lineChart() simultaneously or in one window ?

Having this code in one file:

library(quantmod)

getSymbols("XPT/USD",src="oanda") 
getSymbols("XAU/USD",src="oanda")

lineChart(XAUUSD, subset='2018-03::2018-03') 
lineChart(XAUUSD, subset='2018-04::2018-04') 
lineChart(XPTUSD, subset='2018-03::2018-03')
lineChart(XPTUSD, subset='2018-04::2018-04')

When I evaluate the buffer it displays only the last lineChart.

Is this a property of ESS ? I want to clarify that I need the four graphs separately.

标签: rquantmodess

解决方案


quantmod 绘图功能,虽然很好,很强大,但不会尊重par(c(mfrow()))或同样好(但鲜为人知layout()),所以你必须创建新的绘图设备 - 通过x11()window()- 并通过你的操作系统/窗口管理器安排它们.

为了我:

R> x11(); lineChart(XAUUSD, subset='2018-03::2018-03')
R> x11(); lineChart(XAUUSD, subset='2018-04::2018-04') 
R> x11(); lineChart(XPTUSD, subset='2018-03::2018-03')
R> x11(); lineChart(XPTUSD, subset='2018-04::2018-04')

产生

在此处输入图像描述

并注意这是四个不同的窗口。参见dev.new()anddev.next()和那些函数。


推荐阅读