plotColors: Setting Color Options in BVT

plotColorsR Documentation

Setting Color Options in BVT

Description

How to use the plotColors vector to create custom plots and new themes in BVT

Details

In BVT, colors are controlled by a named list of options. Each theme has a plotColor list associated with it. Like theme options detailed in bvt_graphic_options, a plotColors list can be supplied directly to all BVT functions. The full list does not need to be supplied, but valid list items will selectively override the corresponding plotColors setting in the active theme. For instance plotColors=list(points=c("red","gold","green")) will override just the point color settings. For color settings including "points", "lines", and "fill" that may be associated with factor data, these settings will get associated with the following factors in order of priority: highlight (points only), stack (bar plots only), subgroup, and group. If a single color is given, the color will be applied uniformly (e.g. plotColors=list(fill="blue") will cause all fill colors to be blue in the plot, while plotColors=list(fill=c("blue","green")) will cause the fill to alternate between blue and green based on subgroup or group factor levels.). If a unique color is desired for each factor level, it is important that the coresponding plotColors setting has a length equal to or greater than the number of factor levels. For highlight and stack, where alternating colors may be critical to the plot and where "points" or "fill" are of length one, respectively, BVT will automatically check to see if "fill", "points", or "lines" are length greater than one and will use the those colors as an alternative, only when "highlight" or "stack" is active. Finally, the setAlpha function provides a convenient way to assign an alpha transparency value to any valid R color including named colors such as "steelblue" or "purple". Below is a list of all the valid plotColors settings:

bg

Sets the color of the plotting area or canvas. Must be of length 1. Setting this to "open" will make a transparent background with out the full bounding box (i.e. only the axes are drawn.)

marginBg

Sets the background color for the margins around the the plotting area were the axis labels, titles, etc. are drawn. Must be length 1. Note that if "bg" is set to "open", this will set the background for the entire plot.

guides

Color of the guide lines corresponding to the major tick marks. Providing more than one color will cause the guides to cycle through them in order.

minorGuides

Color of the guide lines corresponding to the minor tick marks. Providing more than one color will cause the guides to cycle through them in order.

lines

Color of line features in the plot. Providing more than one color will cause line color to alternate based on its associated factor as described above.

points

Color of the data point features in the plot. Providing more than one color will cause point colors to alternate based on its associated factor as described above. If this is length one and highlight is active, which needs more than one color to work, fill and lines color schemes may be used instead.

fill

Fill color for features in the plot. Providing more than one color will cause fill colors to alternate based on its associated factor as described above. If this is length one and stack is active, which needs more than one color to work, points and lines color schemes may be used instead.

axis

Sets the color of the axes.

majorTick

Color of the major tick marks. Currently, only the first color is used.

minorTick

Color of the minor tick marks. Currently, only the first color is used.

title

Color of the plot title. Currently, this must be a length one vector

numbers

Color of the numeric labels for the plots. Typically, this is the y-axis, but can include the x and z axes for scatter plots. Currently, this must be a length one vector.

subtext

Color of the subtitle, if present. Currently, this must be a length one vector.

labels

Sets the color of the group factor labels on the categorical axis. If more than one color is given, the colors with cycle through the factor levels, repeating as necessary. Note that the text of the group levels can be customized using the groupLabels option.

subgroupLabels

Sets the color of the group factor labels on the categorical axis. If more than one color is given, the colors with cycle through the factor levels, repeating as necessary. Note that the text of the group levels can be customized using the groupLabels option.

axisLabels

Sets the color of the overall axis label/title. This is is distinct from numeric and group labels associated with the major tick marks. This must be a length one vector.

legendLineCol

Sets the color of the optional boundry box around the square color lables in the legend. Only the first color is used.

legendBG

Sets the background color for the legend. Default is NA which levels the background transparent. Appears to be broken in the current build.

vioBoxFill

Sets the fill color for the box plot embedded in a violin plot. The fill option will set the fill color for the violin overall, but this can be used to color the internal area of the box and whisker plot separately. Supports multiple colors and will cycle like the fill option with factor levels.

vioBoxLineCol

Sets the line color for the box plot embedded in a violin plot. The lines option will set the line color for the violin, but this can be used to set the line color of the box and whisker plot separately. Supports multiple colors and will cycle like the lines option with factor levels.

scaleDefaultColor

Place holder for color spectrum settings used when setting color to a continuos variable. Not currently supported.

See Also

bvt_graphic_options, genePlot, isoPlot, geneScatter, newNPTheme

Examples

#Using plotColors on the fly
data(iris)
library(purrr)
new_colors<-map_chr(c("red","blue","green"), setAlpha, alpha=.5)
pcList<-list(
  lines=new_colors,
  points=new_colors,
  subgroupLabels=new_colors,
  bg="lightgrey",
  fill="white")

genePlot(t(iris[,1:2]), group=iris$Species, plotColors=pcList, main="Color Example")

#Making a new theme based on npGGTheme
customTheme<-newNPTheme(theme=npGGTheme, plotColors = pcList, errorBarLineType=1, fontFamily="sans")
genePlot(t(iris[,1:2]), group=iris$Species, theme=customTheme, main="Theme Example")
npThemes()


ZachHunter/bvt documentation built on Sept. 18, 2024, 3:12 p.m.