chart.Correlation ignores cex arguments
I've tried all versions of these, but nothing has any effect. I"m trying to plot about a 20x20 matrix, and the R values in the upper diagonal are unreadably tiny
PerformanceAnalytics::chart.Correlation(histogram=TRUE, pch=19, cex.cor = 50, cex.labels = 50, cex = 1.5, cex.font = 50)
example:
mtcars %>% PerformanceAnalytics::chart.Correlation(histogram = T, pch = 19, cex = 20)
certainly happy to accept a patch on this, but my initial attempts to allow you to pass a cex multiplier all fail
@@ -36,16 +36,20 @@ function (R, histogram = TRUE, method=c("pearson", "kendall", "spearman"), ...)
if(missing(method)) method=method[1] #only use one
cormeth <- method
+ if(hasArg(cex.cor)) cex.cor <- list(...)$cex.cor
+ else cex.cor <- NULL
# Published at http://addictedtor.free.fr/graphiques/sources/source_137.R
- panel.cor <- function(x, y, digits=2, prefix="", use="pairwise.complete.obs", method=cormeth, cex.cor, ...)
+ panel.cor <- function(x, y, digits=2, prefix="", use="pairwise.complete.obs", method=cormeth, cex.cor=cex.cor, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- cor(x, y, use=use, method=method) # MG: remove abs here
txt <- format(c(r, 0.123456789), digits=digits)[1]
txt <- paste(prefix, txt, sep="")
- if(missing(cex.cor)) cex <- 0.8/strwidth(txt)
-
+ if(is.null(cex.cor)) cex <- 0.8/strwidth(txt)
+ else cex <- cex.cor*0.8/strwidth(txt)
test <- cor.test(as.numeric(x),as.numeric(y), method=method)
# borrowed from printCoefmat
Signif <- symnum(test$p.value, corr = FALSE, na = FALSE,
causes a recursive evaluation of cex.cor
Ah, I thought the function was supposed to be there already. In the help it says that ... can be any other passthru parameters into pairs
Hi - am I facing a similar issue? I tried the following MWE:
require(quantmod)
getSymbols('YJ1306.T', from="1900-01-01", src = 'yahooj')
init.d <- index(YJ1306.T)[1]
etf1306 <- YJ1306.T[, 6]/as.numeric(YJ1306.T[init.d, 6])
names(etf1306) <- "Topix Total Return Index"
PerformanceAnalytics::chart.TimeSeries(etf1306, cex.main = 3)
And whatever number i use in lieu of 3 produces the exact same chart. I thought it was meant to scale the size of the legend? I tried to dig into the subfunction PerformanceAnalytics:::chart.TimeSeries.base - but i don't see cex used there anywhere - am I wrong to say that it does not look implemented? I am not an expert, so I certainly hope my ignorance is not annoying anyone here, not my goal! thank you for the help. thomas
Note: The reason i want to access cex is that i am including my R plot into a beamer slide produced with bookdown and when i do so, the legends on the slides are too small to read comfortably, so i thought i'd increase their font during chart production.
As a matter of fact, I just reran the sample from your documentation:
# These are start and end dates, formatted as xts ranges.
## http://www.nber.org-cycles.html
cycles.dates<-c("1857-06/1858-12",
"1860-10/1861-06",
"1865-04/1867-12",
"1869-06/1870-12",
"1873-10/1879-03",
"1882-03/1885-05",
"1887-03/1888-04",
"1890-07/1891-05",
"1893-01/1894-06",
"1895-12/1897-06",
"1899-06/1900-12",
"1902-09/1904-08",
"1907-05/1908-06",
"1910-01/1912-01",
"1913-01/1914-12",
"1918-08/1919-03",
"1920-01/1921-07",
"1923-05/1924-07",
"1926-10/1927-11",
"1929-08/1933-03",
"1937-05/1938-06",
"1945-02/1945-10",
"1948-11/1949-10",
"1953-07/1954-05",
"1957-08/1958-04",
"1960-04/1961-02",
"1969-12/1970-11",
"1973-11/1975-03",
"1980-01/1980-07",
"1981-07/1982-11",
"1990-07/1991-03",
"2001-03/2001-11",
"2007-12/2009-06"
)
# Event lists - FOR BEST RESULTS, KEEP THESE DATES IN ORDER
risk.dates = c(
"Oct 87",
"Feb 94",
"Jul 97",
"Aug 98",
"Oct 98",
"Jul 00",
"Sep 01")
risk.labels = c(
"Black Monday",
"Bond Crash",
"Asian Crisis",
"Russian Crisis",
"LTCM",
"Tech Bubble",
"Sept 11")
data(edhec)
R=edhec[,"Funds of Funds",drop=FALSE]
Return.cumulative = cumprod(1+R) - 1
chart.TimeSeries(Return.cumulative)
chart.TimeSeries(Return.cumulative, colorset = "darkblue",
legend.loc = "bottomright",
period.areas = cycles.dates,
period.color = "lightblue",
event.lines = risk.dates,
event.labels = risk.labels,
event.color = "red", lwd = 2)
and added
, cex.main = 5
just before the last ) and the chart produced was identical...
Ah, I thought the function was supposed to be there already. In the help it says that
...can be any other passthru parameters intopairs
Did you figure out how to modify "cex"? And would you have any comments regarding my post at https://github.com/braverock/PerformanceAnalytics/issues/126? Thanks!
@gnmcsbnfrmtcsclb and others: that chart is very complicated, and was cribbed from the now defunct rcharts site, as mentioned in the documentation. As I've said previously, I'm happy to work with someone motivated to work on a patch, but without outside contribution this is unlikely to reach the top of my very long queue of things to do.