\HeaderA{legend.CSP}{Makes a rough legend for the ContourScatterPlot}{legend.CSP}
\keyword{hplot}{legend.CSP}
\begin{Description}\relax
The color scheme used for the \LinkA{image}{image} plot within the
\LinkA{ContourScatterPlot}{ContourScatterPlot} is scaled according the rough estimates of
the breaks.  Any white-colored cells in an \LinkA{image}{image} or
\LinkA{ContourScatterPlot}{ContourScatterPlot} is considered to be NA.
\end{Description}
\begin{Usage}
\begin{verbatim}
legend.CSP(z, n,
   border = if (n < 32) "light gray" else NA,
   main = paste("color palettes;  n=", n),
   ch.col = c("rainbow(n, start=.7, end=.1)",
            "heat.colors(n)", "terrain.colors(n)",
            "topo.colors(n)", "cm.colors(n)"),
            breaks = seq(range(z, na.rm = TRUE)[1],
                  range(z, na.rm = TRUE)[2],
                  by = diff(range(z, na.rm = TRUE))/n))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{z}] The matrix grid used for the \LinkA{image}{image} plot; this matrix
is produced via \LinkA{make.grid}{make.grid} or \LinkA{make.density}{make.density} 
\item[\code{n}] The number of color levels
\item[\code{border}] The border of the legend plot
\item[\code{main}] The main title of the legend plot
\item[\code{ch.col}] the color palette used 
\item[\code{breaks}] the breaks used to scale the color scheme
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This legend is used as a rough approximation and is produced in a plot
entirely separate.
\end{Details}
\begin{Value}
Plot of the color scheme scaled by ranges of the values of the grid
cells in the \LinkA{image}{image} plot produced by 'z' input.
\end{Value}
\begin{Author}\relax
A.J. Rossini and J.Y. Wan
\end{Author}
\begin{References}\relax
The code was obtained from the example of \LinkA{heat.colors}{heat.colors}
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{heat.colors}{heat.colors}},
\code{\LinkA{ContourScatterPlot}{ContourScatterPlot}},
\code{\LinkA{image}{image}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  if (require(rfcdmin)){
   data.there<-is.element(c("st.1829", "unst.1829", "st.DRT", "unst.DRT"),objects())
   if ( ( sum(data.there) != length(data.there) )){
      ## obtaining the FCS objects from VRC data
      data(VRCmin)
  }

var1<-st.DRT@data[,4]
var2<-st.DRT@data[,5]

col.nm<-colnames(st.DRT@data)

## matrix of counts
count.output1<-make.grid(var1, var2)
mat.counts1<-count.output1$z
if (interactive()){
par(mfrow=c(2,2))

image(mat.counts1,
  main="make.grid: Counts for stimulated",
   xlab=col.nm[4],yaxt="n", xaxt="n",
   ylab=col.nm[5], col=heat.colors(20))

## legend describes the counts in each cell
legend.CSP(mat.counts1, 20, ch.col="heat.colors(n)")

image(mat.counts1,yaxt="n", xaxt="n",
  main="make.grid: Counts for stimulated",
   xlab=col.nm[4],
   ylab=col.nm[5], col=topo.colors(20))

legend.CSP(mat.counts1, 20, ch.col="topo.colors(n)")

}

}
\end{ExampleCode}
\end{Examples}

