2013-10-05 40 views

回答

4
cspy <- chart_Series(SPY) 
cspy$Env$actions[[3]] 
#------------------ 
expression(axt <- axTicksByTime(xdata[xsubset], format.labels = format.labels), 
    axis(1, at = axt, labels = names(axt), las = 1, lwd.ticks = 1, 
     mgp = c(3, 1.5, 0), tcl = -0.4, cex.axis = 0.9)) 
attr(,"frame") 
[1] 1 
attr(,"clip") 
[1] TRUE 
attr(,"env") 
<environment: 0x11cddc148> 

您需要保存的属性,使他们可以在放回去,你需要的format.labels更改为新的规格,然后从AXT载体,而不是他们的价值使用的名称。 las参数是基本图形的旋转指示符。见?par

attrs <- attributes(cspy$Env$actions[[3]]) 
cspy$Env$actions[[3]] <- 
     expression(axt <- axTicksByTime(xdata[xsubset], format.labels = "%b %d"), 
     axis(1, at = axt, labels = names(axt), las = 2, lwd.ticks = 1, 
     mgp = c(3, 1.5, 0), tcl = -0.4, cex.axis = 0.9)) 
attributes(cspy$Env$actions[[3]]) <- attrs 
cspy 

enter image description here

+0

非常感谢您的帮助。 –

3

可以使用

myTheme <- chart_theme() 
myTheme$format.labels <- '%b %d' 
chart_Series(SPY,theme=myTheme) 

这应该给你创建你的主题下面

enter image description here

+0

旋转标签? ('chart_theme'抛出las = 2的错误。) –

+0

@DWin哦错过了标签部分的旋转。 –

+0

非常感谢您的帮助。 –