Create a custom color palette in R - r
I know that R is loaded with some color palettes automatically, such as palette, rainbow , heat.colors and gray. I'm also aware of RColorBrewer. But, what if I want to use a custom color palette and assign colors by name? Is that possible?
My company's color palette is as follows:
#1A73BA (R: 26 G: 115 B: 186) - this is a blue
#FFDB43 (R:255 G:219 B:67) - this is a yellow
#B54B05 (R:181 G:75 B:5) - this is an orange
My company's initials are AT.
I'd like to be able to call those colors via a name rather than by the HEX or RGB because I don't remember them. Ideally, I could create a file that would load into R automatically that would initiate these colors.
ATBlue <- #1A73BA
ATYellow <- #FFDB43
ATOrange <- #B54B05
Then, I could call the colors:
plot(x,y, col = "ATBlue")
I could put the values into a dataframe, then call them like so:
ATColors <- data.frame(name = c("ATBlue", "ATYellow", "ATOrange"), color= c("#1A73BA", "#F7D364", "#B54B05"))
plot(x,y, col = ATColors[3,2])
But I would need to know the location in the dataframe in order to call it correctly.
Can I create an element that will automatically load when R launches that would allow me call a custom color name into a plot?
This answers (or at least is one possible answer to) your comments and edits:
ATblue <- rgb(26/255, 115/255, 186/255, 1)
ATyellow <- rgb(255/255, 219/255, 67/255, 1)
ATorange <- rgb(181/255, 75/255, 5/255, 1)
plot(1:10, col= c(ATblue, ATyellow, ATorange), pch=20)
The definition method with rgb allows you to set an alpha level , thus allowing transparency on graphic devices that support it (at a minimum: 'pdf', 'windows', 'quartz' and 'X11').
You can also name a 'palette-vector'
palvec <- c(ATblue=ATblue, ATyellow=ATyellow, ATorange=ATorange)
That vector could be accessed with either numbers or names:
plot(1,1) # to set up plot window
abline(h=c(0.8,1,1.2), col= palvec[ c( 'ATblue', 'ATyellow', 'ATorange' ) ] , lwd=40)
In general I think you will find that if you use all lower case there will be good correspondence for the base and graphics packages (loaded by default so no renaming will be necessary) with that gif-list. So it's already part of R. Let's say you wanted to find the R color name of "LavenderBlush". The vector of assigned color names is returned from colors() but it's rather big, so you can whittle it down with:
grep("lavender", colors(), ignore.case=TRUE, value=TRUE)
#[1] "lavender" "lavenderblush" "lavenderblush1" "lavenderblush2"
# "lavenderblush3" "lavenderblush4"
And say you wanted to see whether the Hex code for that color were the same as the one on your unreadable gif table:
ccodes <- as.hexmode( c(256^(2:0) %*% col2rgb("lavenderblush")) )
ccodes
#[1] "fff0f5"
Yep. And for your example just use "seagreen":
> ccodes <- as.hexmode( c(256^(2:0) %*% col2rgb("seagreen")) )
> ccodes
[1] "2e8b57
If you have a hex-code value you can append "#" to it with paste0:
paste0("#", ccodes)
#[1] "#2e8b57"
plot(1,1, col=paste0("#", ccodes) )
If you have a vector of such values, paste0 is also vectorized:
ccodes <- as.hexmode( c(256^(2:0) %*% col2rgb(colors()[20:25])) )
paste0("#", ccodes)
#[1] "#ffe4c4" "#eed5b7" "#cdb79e" "#8b7d6b" "#000000" "#ffebcd"
I would put the colours in a named vector like this:
ATcols <- c(blue = "#1A73BA", yellow = "#FFDB43", orange = "#B54B05")
Then you can get, say, blue like this: ATcols["blue"].
If you want to be a bit fancier, you could create a named vector and a function:
AT_color_data <- c(blue = "#1A73BA", yellow = "#FFDB43", orange = "#B54B05")
ATcolor <- function(color="blue") {
if (is.numeric(color)) AT_color_data[color]
else AT_color_data[tolower(color)]
}
This gives you a few options for getting your colours:
ATcolor(2:3)
# yellow orange
# "#FFDB43" "#B54B05"
ATcolor("orange")
# orange
# "#B54B05"
ATcolor(c("orange", "blue"))
# orange blue
# "#B54B05" "#1A73BA"
Alternatively, you could make your function behave a bit more like rainbow when providing a numeric argument:
AT_color_data <- c(blue = "#1A73BA", yellow = "#FFDB43", orange = "#B54B05")
ATcolor <- function(color="blue") {
if (is.numeric(color)) AT_color_data[1:color[1]]
else AT_color_data[tolower(color)]
}
then, for example:
ATcolor(2)
# blue yellow
# "#1A73BA" "#FFDB43"
library("grDevices")
plot(1:20,pch=20,col=col)
col=colorRampPalette(c("white", "red"))(20)
M <- matrix(runif(100),10,10)
M[lower.tri(M)] <- NA
image(M,col = col,frame=F,xaxt="n",yaxt="n")
Related
Using ggplot2 why does changing the color palette result in all grey?
Built into my app I have the ability to change the color palette including for color vision deficiencies. However, one of my graphs works fine with the R4 but is all grey with the Okabe-Ito palette and lists the colors' names in the legend. What am I doing wrong? data<-as.data.frame(rbind(15.29,84.71)) data<-cbind(x=c("Total Measurement Variance","Total Measurement Variance"),y=data,Group=c("Repeatability","Reproducibility")) colnames(data)<-c("x","y","Source") color=palette.colors(n = 8,palette = "R4") p<-ggplot(data=data,aes(x=x,y=y,fill=Source,label=y))+ geom_bar(stat="identity")+ geom_label(aes(group=Source),fill="white",label=paste0(data$y,"%"),position=position_stack(vjust=.5))+ scale_y_continuous(labels=function (x) paste0(x,"%"))+ scale_fill_manual(values=color[-1])+ labs(title="Components of Variation",x="",y="% of Measurement Error Variance") p color=palette.colors(n = 8,palette = "Okabe-Ito") p<-ggplot(data=data,aes(x=x,y=y,fill=Source,label=y))+ geom_bar(stat="identity")+ geom_label(aes(group=Source),fill="white",label=paste0(data$y,"%"),position=position_stack(vjust=.5))+ scale_y_continuous(labels=function (x) paste0(x,"%"))+ scale_fill_manual(values=color[-1])+ labs(title="Components of Variation",x="",y="% of Measurement Error Variance") p
The problem comes from the fact that for some reason, palette.colors returns a named vector when you use palette = "Okabe-Ito" Compare the output here palette.colors(n = 8,palette = "R4") # [1] "#000000" "#DF536B" "#61D04F" "#2297E6" "#28E2E5" "#CD0BBC" # [7] "#F5C710" "#9E9E9E" palette.colors(n = 8,palette = "Okabe-Ito") # black orange skyblue bluishgreen # "#000000" "#E69F00" "#56B4E9" "#009E73" # yellow blue vermillion reddishpurple # "#F0E442" "#0072B2" "#D55E00" "#CC79A7" When you use scale_fill_manual(values=), if you pass a named vector, then it will try to match up the names of in the color vector to the names of the levels of your factor. Since your Source values are "Repeatability" and "Reproducibility" and not values like "orange" and "skyblue", the matching doesn't work and you just get grey. If you remove the names, then it won't try to do the matching. color <- unname(palette.colors(n = 8, palette = "Okabe-Ito")) should work
Using R to read out excel-colorinfo
Is there any way to read out the color-index of cells from excel files with R? While I can set the cell color with packages like XLConnect or XLSX, I have found no way to extract the color-information from existing workbooks.
R-Bloggers provided a function that will do the job for you. I am including the answer here for future reference. Read the excel file using xlsx package: library(xlsx) wb <- loadWorkbook("test.xlsx") sheet1 <- getSheets(wb)[[1]] # get all rows rows <- getRows(sheet1) cells <- getCells(rows) This part extracts the information that later will be used for getting background color (or other style information) of the cells: styles <- sapply(cells, getCellStyle) #This will get the styles This is the function that identifies/extracts the cell background color: cellColor <- function(style) { fg <- style$getFillForegroundXSSFColor() rgb <- tryCatch(fg$getRgb(), error = function(e) NULL) rgb <- paste(rgb, collapse = "") return(rgb) } error will handle the cells with no background color. Using sapply you can get the background color for all of the cells: sapply(styles, cellColor) You can also categorize/identify them by knowing the RGb codes: mycolor <- list(green = "00ff00", red = "ff0000") m <- match(sapply(styles, cellColor), mycolor) labs <-names(mycolor)[m] You can read more and learn how to apply it at R-bloggers You can get the RGB codes from RapidTables.com
Old question but maybe it can help someone in the future. There is a strange behavior in the POI (java) library (at least on my computer). It is not getting the colors correctly. The code provided in the #M--'s answer works well when the color is a basic color (indexed color), but does not work when the color is, for example, in grayscale. To get around you can use the following code using the getTint () function. Tint is a number between -1 (dark) and 1 (light), and combining it with the RGB (getRgb ()) function, you can completely recover the color. cell_color <- function(style){ fg <- style$getFillForegroundXSSFColor() hex <- tryCatch(fg$getRgb(), error = function(e) NULL) hex <- paste0("#", paste(hex, collapse = "")) tint <- tryCatch(fg$getTint(), error = function(e) NULL) if(!is.null(tint) & !is.null(hex)){ # Tint varies between -1 (dark) and 1 (light) rgb_col <- col2rgb(col = hex) if(tint < 0) rgb_col <- (1-abs(tint))*rgb_col if(tint > 0) rgb_col <- rgb_col + (255-rgb_col)*tint hex <- rgb(red = rgb_col[1, 1], green = rgb_col[2, 1], blue = rgb_col[3, 1], maxColorValue = 255) } return(hex) } Some references to help: https://poi.apache.org/apidocs/dev/org/apache/poi/hssf/usermodel/HSSFExtendedColor.html#getTint-- https://bz.apache.org/bugzilla/show_bug.cgi?id=50787 Getting Excel fill colors using Apache POI
Convert ashape3d class to mesh3d
Can somebody help me convert an 'ashape3d' class object to class 'mesh3d'? In ashape3d, the triangle en tetrahedron faces are are stored in different fields. As I don't think there's a function that can create a mesh3d object from triangles&tetrahedrons simultaneously, I tried the following (pseudocode): model <- ashape3d(rtorus(1000, 0.5, 2),alpha=0.25) vert <- model$x[model$vert[,2]==1,] vert <- cbind(vert,rep(1,nrow(vert))) tria <- model$triang[model$triang[,4]==1,1:3] tetr <- model$tetra[model$tetra[,6]==1,1:4] m3dTria <- tmesh3d(vertices=vert , indices=tria) m3dTetr <- qmesh3d(vertices=vert , indices=tetr) m3d <- mergeMeshes(m3dTria,m3dTetr) plot.ashape3d(model) # works fine plot3d(m3d) # Error in x$vb[1, x$it] : subscript out of bounds Does anybody have a better way?
I needed to do this recently and found this unanswered question. The easiest way to figure out what is going on is to look at plot.ashape3d and read the docs for ashape3d. plot.ashape3d only plots triangles. The rgl package has a generic as.mesh3d function. This defines a method for that generic function. as.mesh3d.ashape3d <- function(x, ...) { if (length(x$alpha) > 1) stop("I don't know how to handle ashape3d objects with >1 alpha value") iAlpha = 1 # from help for ashape3d # for each alpha, a value (0, 1, 2 or 3) indicating, respectively, that the # triangle is not in the alpha-shape or it is interior, regular or singular # (columns 9 to last) # Pick the rows for which the triangle is regular or singular selrows = x$triang[, 8 + iAlpha] >= 2 tr <- x$triang[selrows, c("tr1", "tr2", "tr3")] rgl::tmesh3d( vertices = t(x$x), indices = t(tr), homogeneous = FALSE ) } You can try it out on the data above model <- ashape3d(rtorus(1000, 0.5, 2),alpha=0.25) plot(model, edges=F, vertices=F) library(rgl) model2=as.mesh3d(model) open3d() shade3d(model2, col='red')
How to automatically generate legend for line graphs in R
all, I have following R script. To give credit, it's based on a script I got from http://www.statmethods.net/graphs/line.html, and applied to my own data. Perhaps you can tell that I am new to R. Following script generates auto legend and labels it as 1,2,3. Instead I want the script to print "sample names as text" instead of numbers. I was wondering if anyone can help me with this. Thank you. # Create Line Chart fd<- read.csv ("indata", header=TRUE) ## convert factor to numeric for convenience fd$sampleN <- as.numeric(fd$sampleN) nfd <- max(fd$sampleN) # get the range for the x and y axis xrange <- range(fd$gc) #yrange <- range(fd$coverage) yrange <- range(0,2) #you can customize this one. # set up the plot plot(xrange, yrange, type="n", xlab="gc", ylab="nc" ) colors <- rainbow(nfd) linetype <- c(1:nfd) plotchar <- seq(18,18+nfd,1) # add lines for (i in 1:nfd) { tree <- subset(fd, sampleN==i) lines(tree$gc, tree$coverage, type="b", lwd=1.5, lty=linetype[i], col=colors[i], pch=plotchar[i]) } # add a title and subtitle title("metrics", "") # add a legend legend(xrange[1], yrange[2], 1:nfd, cex=0.8, col=colors, pch=plotchar, lty=linetype, title="Samples") Input data is below: sampleN,gc,coverage sample_metrics1,0,0.24558 sample_metrics1,1,0.05663 sample_metrics1,2,0.088432 sample_metrics1,3,0.117296 sample_metrics1,4,0.169752 sample_metrics1,5,0.228159 sample_metrics1,6,0.333096 sample_metrics1,7,0.427725 sample_metrics1,8,0.428772 sample_metrics1,9,0.502811 sample_metrics1,10,0.580475 sample_metrics1,11,0.649858 sample_metrics1,12,0.686928 sample_metrics1,13,0.76773 sample_metrics1,14,0.817875 sample_metrics1,15,0.862198 sample_metrics1,16,0.878292 sample_metrics1,17,0.90871 sample_metrics1,18,0.910914 sample_metrics1,19,0.949483 sample_metrics1,20,0.931209 sample_metrics1,21,0.935704 sample_metrics1,22,0.945239 sample_metrics1,23,0.927157 sample_metrics1,24,0.930656 sample_metrics1,25,0.935901 sample_metrics1,26,0.932245 sample_metrics1,27,0.934365 sample_metrics1,28,0.937328 sample_metrics1,29,0.94063 sample_metrics1,30,0.943312 sample_metrics1,31,0.950184 sample_metrics1,32,0.963963 sample_metrics1,33,0.984982 sample_metrics1,34,1.003258 sample_metrics1,35,1.023331 sample_metrics1,36,1.045045 sample_metrics1,37,1.057649 sample_metrics1,38,1.067116 sample_metrics1,39,1.067653 sample_metrics1,40,1.063026 sample_metrics1,41,1.052287 sample_metrics1,42,1.040282 sample_metrics1,43,1.020074 sample_metrics1,44,1.000212 sample_metrics1,45,0.9896 sample_metrics1,46,0.985244 sample_metrics1,47,0.985526 sample_metrics1,48,0.982893 sample_metrics1,49,0.981362 sample_metrics1,50,0.979265 sample_metrics1,51,0.979916 sample_metrics1,52,0.979846 sample_metrics1,53,0.984885 sample_metrics1,54,0.986803 sample_metrics1,55,0.994042 sample_metrics1,56,0.996345 sample_metrics1,57,1.007551 sample_metrics1,58,1.003795 sample_metrics1,59,1.008586 sample_metrics1,60,1.01787 sample_metrics1,61,1.02482 sample_metrics1,62,1.020601 sample_metrics1,63,1.018051 sample_metrics1,64,1.035102 sample_metrics1,65,1.025948 sample_metrics1,66,1.03562 sample_metrics1,67,1.040274 sample_metrics1,68,1.036387 sample_metrics1,69,1.058105 sample_metrics1,70,1.06795 sample_metrics1,71,1.064344 sample_metrics1,72,1.049132 sample_metrics1,73,1.071662 sample_metrics1,74,1.08023 sample_metrics1,75,1.09954 sample_metrics1,76,1.14631 sample_metrics1,77,1.172438 sample_metrics1,78,1.175826 sample_metrics1,79,1.211766 sample_metrics1,80,1.208507 sample_metrics1,81,1.217303 sample_metrics1,82,1.262392 sample_metrics1,83,1.331984 sample_metrics1,84,1.383047 sample_metrics1,85,1.416259 sample_metrics1,86,1.583698 sample_metrics1,87,1.785849 sample_metrics1,88,1.857123 sample_metrics1,89,2.114804 sample_metrics1,90,1.991428 sample_metrics1,91,1.976769 sample_metrics1,92,2.216659 sample_metrics1,93,1.606086 sample_metrics1,94,1.821604 sample_metrics1,95,5.19378 sample_metrics1,96,2.46372 sample_metrics1,97,9.844896 sample_metrics1,98,17.281094 sample_metrics1,99,10.147151 sample_metrics1,100,0 sample_metrics2,0,0.27566 sample_metrics2,1,0.052443 sample_metrics2,2,0.060661 sample_metrics2,3,0.142456 sample_metrics2,4,0.110315 sample_metrics2,5,0.195035 sample_metrics2,6,0.266574 sample_metrics2,7,0.256115 sample_metrics2,8,0.332823 sample_metrics2,9,0.341872 sample_metrics2,10,0.335247 sample_metrics2,11,0.480877 sample_metrics2,12,0.40355 sample_metrics2,13,0.452441 sample_metrics2,14,0.522209 sample_metrics2,15,0.489945 sample_metrics2,16,0.51272 sample_metrics2,17,0.538931 sample_metrics2,18,0.58408 sample_metrics2,19,0.600836 sample_metrics2,20,0.615026 sample_metrics2,21,0.631172 sample_metrics2,22,0.651189 sample_metrics2,23,0.653251 sample_metrics2,24,0.679981 sample_metrics2,25,0.69569 sample_metrics2,26,0.71077 sample_metrics2,27,0.735305 sample_metrics2,28,0.754265 sample_metrics2,29,0.778111 sample_metrics2,30,0.804297 sample_metrics2,31,0.831779 sample_metrics2,32,0.863024 sample_metrics2,33,0.894018 sample_metrics2,34,0.937245 sample_metrics2,35,0.985043 sample_metrics2,36,1.029299 sample_metrics2,37,1.069061 sample_metrics2,38,1.094257 sample_metrics2,39,1.102138 sample_metrics2,40,1.114504 sample_metrics2,41,1.11484 sample_metrics2,42,1.111952 sample_metrics2,43,1.108918 sample_metrics2,44,1.090665 sample_metrics2,45,1.082678 sample_metrics2,46,1.076516 sample_metrics2,47,1.08798 sample_metrics2,48,1.093462 sample_metrics2,49,1.08452 sample_metrics2,50,1.090786 sample_metrics2,51,1.093115 sample_metrics2,52,1.101703 sample_metrics2,53,1.107301 sample_metrics2,54,1.11793 sample_metrics2,55,1.130198 sample_metrics2,56,1.141167 sample_metrics2,57,1.155742 sample_metrics2,58,1.165464 sample_metrics2,59,1.157386 sample_metrics2,60,1.167818 sample_metrics2,61,1.166827 sample_metrics2,62,1.135574 sample_metrics2,63,1.128703 sample_metrics2,64,1.130197 sample_metrics2,65,1.089628 sample_metrics2,66,1.048679 sample_metrics2,67,1.024862 sample_metrics2,68,0.951014 sample_metrics2,69,0.863408 sample_metrics2,70,0.741022 sample_metrics2,71,0.661516 sample_metrics2,72,0.545033 sample_metrics2,73,0.433509 sample_metrics2,74,0.367888 sample_metrics2,75,0.275933 sample_metrics2,76,0.148513 sample_metrics2,77,0.104557 sample_metrics2,78,0.09074 sample_metrics2,79,0.035399 sample_metrics2,80,0.038729 sample_metrics2,81,0.013173 sample_metrics2,82,0.011767 sample_metrics2,83,0.019057 sample_metrics2,84,0.012294 sample_metrics2,85,0 sample_metrics2,86,0 sample_metrics2,87,0 sample_metrics2,88,0 sample_metrics2,89,0 sample_metrics2,90,0 sample_metrics2,91,0 sample_metrics2,92,0 sample_metrics2,93,0 sample_metrics2,94,0 sample_metrics2,95,6.012146 sample_metrics2,96,0 sample_metrics2,97,10.129887 sample_metrics2,98,5.080385 sample_metrics2,99,12.529071 sample_metrics2,100,0 genome_windows,0,0.000831175 genome_windows,1,0.000594994 genome_windows,2,0.0006862 genome_windows,3,0.000876388 genome_windows,4,0.000942013 genome_windows,5,0.000958863 genome_windows,6,0.001091706 genome_windows,7,0.001176513 genome_windows,8,0.001343131 genome_windows,9,0.001520906 genome_windows,10,0.001799756 genome_windows,11,0.002206363 genome_windows,12,0.002886519 genome_windows,13,0.003815775 genome_windows,14,0.005416344 genome_windows,15,0.007978863 genome_windows,16,0.011943919 genome_windows,17,0.017942331 genome_windows,18,0.026916138 genome_windows,19,0.039731306 genome_windows,20,0.057394938 genome_windows,21,0.080734088 genome_windows,22,0.110251175 genome_windows,23,0.146365406 genome_windows,24,0.188943563 genome_windows,25,0.236974131 genome_windows,26,0.288641038 genome_windows,27,0.342599325 genome_windows,28,0.397027756 genome_windows,29,0.449998694 genome_windows,30,0.500295781 genome_windows,31,0.546689806 genome_windows,32,0.587357375 genome_windows,33,0.621426481 genome_windows,34,0.647914206 genome_windows,35,0.66795535 genome_windows,36,0.680710806 genome_windows,37,0.684866219 genome_windows,38,0.678578188 genome_windows,39,0.663729056 genome_windows,40,0.642785275 genome_windows,41,0.617580269 genome_windows,42,0.5895275 genome_windows,43,0.561500825 genome_windows,44,0.536200638 genome_windows,45,0.514647113 genome_windows,46,0.496522031 genome_windows,47,0.481198119 genome_windows,48,0.465125163 genome_windows,49,0.445097106 genome_windows,50,0.419522256 genome_windows,51,0.389562975 genome_windows,52,0.358433044 genome_windows,53,0.329269363 genome_windows,54,0.30327115 genome_windows,55,0.280368106 genome_windows,56,0.258316269 genome_windows,57,0.234869275 genome_windows,58,0.209039444 genome_windows,59,0.181009944 genome_windows,60,0.152880644 genome_windows,61,0.126921669 genome_windows,62,0.104752206 genome_windows,63,0.086465069 genome_windows,64,0.071383019 genome_windows,65,0.058826631 genome_windows,66,0.048428619 genome_windows,67,0.039328369 genome_windows,68,0.031444125 genome_windows,69,0.025158775 genome_windows,70,0.020178806 genome_windows,71,0.01616445 genome_windows,72,0.013079681 genome_windows,73,0.0106774 genome_windows,74,0.008807444 genome_windows,75,0.007423456 genome_windows,76,0.006410344 genome_windows,77,0.005637675 genome_windows,78,0.005014725 genome_windows,79,0.0043783 genome_windows,80,0.003736631 genome_windows,81,0.003142294 genome_windows,82,0.002639056 genome_windows,83,0.002170913 genome_windows,84,0.001683113 genome_windows,85,0.001218638 genome_windows,86,0.000809938 genome_windows,87,0.000524731 genome_windows,88,0.000361769 genome_windows,89,0.000234463 genome_windows,90,0.000153681 genome_windows,91,9.75E-05 genome_windows,92,0.000057575 genome_windows,93,3.61E-05 genome_windows,94,0.00002095 genome_windows,95,1.03E-05 genome_windows,96,6.16E-06 genome_windows,97,4.11E-06 genome_windows,98,0.00000205 genome_windows,99,8.31E-07 genome_windows,100,2.12E-06
I would use ggplot2 for this: library(ggplot2) ggplot(fd, aes(x = gc, y = coverage, color = sampleN)) + geom_line() This uses the names of factor in the legend, in your case sample_metrics1, etc.
From ?legend, you can see that the third argument (currently 1:nfd) is the text being displayed on the legend. If you wanted to instead use labels A, B, and C, you would replace 1:nfd with c("A", "B", "C").
charts.PerformanceSummary: how to set sequential colors
require(quantmod) require(PerformanceAnalytics) getSymbols(c('SP500', 'WAAA', 'WBAA'), src = 'FRED', from = '1950-01-01') X <- na.omit(merge(to.weekly(SP500), WAAA, WBAA)) dWAAA <- diff(WAAA / 100, 1) dWBAA <- diff(WBAA / 100, 1) D <- 20 dP.WAAA <- - D * dWAAA dP.WBAA <- - D * dWBAA charts.PerformanceSummary(p = .99, R = dP.WAAA['1990-01-01/2012-08-17'], methods = 'ModifiedES', width = 48) charts.PerformanceSummary(p = .99, R = dP.WBAA['1990-01-01/2012-08-17'], methods = 'ModifiedES', width = 48) May you tell me any way to set colors' smoothing-transitions-sequential palette in order to replace default black color with something which looks nicer? I would like something which is blue-based and changes blue variety starting from the 1st plot ending to the 3rd one. Thanks,
See ?chart.TimeSeries. I believe that the options you want are likely: element.color # for the boxes, axes, etc # and colorset # for the actual chart lines # try colorset = 'darkblue' # or colorset = 'lightblue' # as an extra argument to charts.PerformanceSummary The colorsets provide different colors for the different chart elements, and work best when you plot more than one series on the same chart, to compare an asset to an index or a peer group, for example. A vertical color ramp in R is not possible using base graphics, and conveys no information anyway.