Evan Cooch
2016-Jan-11 15:44 UTC
[R] different coloured axis title labels for different axes
Consider a simple plot of X vs Y. There are elements on the plot that represent X, or Y, that are presented in different colours (say, blue for X, red for Y). Rather than use a legend, I would like to have the title label for the X-axis be in blue, and the title label for the Y-axis be in red. While it is trivial to change the color of the axis title labels for *both* axes at the same time, I haven't figured out how to trick thing into generating a blue title label for the X-axis, and a red title label for the Y- axis (i.e., different colours on different axes). I'm sure this is out there on searchable pages, but, I haven't managed to stumble across the appropriate search phrase(s). Pointers to the obvious solution welcomed in advance. Cheers.... [[alternative HTML version deleted]]
Dalthorp, Daniel
2016-Jan-11 17:52 UTC
[R] different coloured axis title labels for different axes
How about this: plot(0,0,xlab='',ylab='') mtext(side=1,line=3,text='x axis',col=4) mtext(side=2,line=3,text='y axis',col=2) -Dan On Mon, Jan 11, 2016 at 7:44 AM, Evan Cooch <evan.cooch at gmail.com> wrote:> Consider a simple plot of X vs Y. There are elements on the plot that > represent X, or Y, that are presented in different colours (say, blue > for X, red for Y). Rather than use a legend, I would like to have the > title label for the X-axis be in blue, and the title label for the > Y-axis be in red. > > While it is trivial to change the color of the axis title labels for > *both* axes at the same time, I haven't figured out how to trick thing > into generating a blue title label for the X-axis, and a red title label > for the Y- axis (i.e., different colours on different axes). > > I'm sure this is out there on searchable pages, but, I haven't managed > to stumble across the appropriate search phrase(s). > > Pointers to the obvious solution welcomed in advance. > > > Cheers.... > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Dan Dalthorp, PhD USGS Forest and Rangeland Ecosystem Science Center Forest Sciences Lab, Rm 189 3200 SW Jefferson Way Corvallis, OR 97331 ph: 541-750-0953 ddalthorp at usgs.gov [[alternative HTML version deleted]]
David Winsemius
2016-Jan-11 18:08 UTC
[R] different coloured axis title labels for different axes
> On Jan 11, 2016, at 7:44 AM, Evan Cooch <evan.cooch at gmail.com> wrote: > > Consider a simple plot of X vs Y. There are elements on the plot that > represent X, or Y, that are presented in different colours (say, blue > for X, red for Y). Rather than use a legend, I would like to have the > title label for the X-axis be in blue, and the title label for the > Y-axis be in red. > > While it is trivial to change the color of the axis title labels for > *both* axes at the same time, I haven't figured out how to trick thing > into generating a blue title label for the X-axis, and a red title label > for the Y- axis (i.e., different colours on different axes). > > I'm sure this is out there on searchable pages, but, I haven't managed > to stumble across the appropriate search phrase(s).Suppress the 'label' production for both x-axis and y-axis "titles" (by assigning them to "") and then use the `title` function (twice) to separately construct your colored labels. I had difficulty learning that the term "label" in hte plot-function documentation referred only to the single valued axis title and not to the multiple numeric or text axis annotations at the tick marks. The word "lable" is used to refer to both sets of values..> > Pointers to the obvious solution welcomed in advance. > > > Cheers.... > > [[alternative HTML version deleted]]Plain text.> > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius Alameda, CA, USA
William Dunlap
2016-Jan-11 18:54 UTC
[R] different coloured axis title labels for different axes
The following shows how to get different colors for most features of a scatterplot: plot(1:11,log(1:11),ann=FALSE,axes=FALSE,col="pink",pch=16) box(col="gray") title(xlab="X Axis Label", col.lab="light blue") title(ylab="Y Axis Label", col.lab="light green") axis(side=1, at=c(2,3,5,7,11), lab=as.expression(lapply(1:5, function(i)bquote(pi[.(i)]))), col.axis="red", col="orange") axis(side=2, at=log(c(2,3,5,7,11)), lab=as.expression(lapply(1:5, function(i)bquote(lambda[.(i)]))), col.axis="blue", col="green") title(main="Main Title", col.main="magenta", sub="(subtitle)", col.sub="yellow") See help(par) for details. The 'cex' and 'font' parameters have same subtypes as 'col'. Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Jan 11, 2016 at 7:44 AM, Evan Cooch <evan.cooch at gmail.com> wrote:> Consider a simple plot of X vs Y. There are elements on the plot that > represent X, or Y, that are presented in different colours (say, blue > for X, red for Y). Rather than use a legend, I would like to have the > title label for the X-axis be in blue, and the title label for the > Y-axis be in red. > > While it is trivial to change the color of the axis title labels for > *both* axes at the same time, I haven't figured out how to trick thing > into generating a blue title label for the X-axis, and a red title label > for the Y- axis (i.e., different colours on different axes). > > I'm sure this is out there on searchable pages, but, I haven't managed > to stumble across the appropriate search phrase(s). > > Pointers to the obvious solution welcomed in advance. > > > Cheers.... > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Evan Cooch
2016-Jan-11 19:05 UTC
[R] different coloured axis title labels for different axes
On 1/11/2016 1:54 PM, William Dunlap wrote:> The following shows how to get different colors for most features of a > scatterplot: > > plot(1:11,log(1:11),ann=FALSE,axes=FALSE,col="pink",pch=16) > box(col="gray") > title(xlab="X Axis Label", col.lab="light blue") > title(ylab="Y Axis Label", col.lab="light green") > axis(side=1, at=c(2,3,5,7,11), lab=as.expression(lapply(1:5, > function(i)bquote(pi[.(i)]))), col.axis="red", col="orange") > axis(side=2, at=log(c(2,3,5,7,11)), lab=as.expression(lapply(1:5, > function(i)bquote(lambda[.(i)]))), col.axis="blue", col="green") > title(main="Main Title", col.main="magenta", sub="(subtitle)", > col.sub="yellow") > > See help(par) for details. The 'cex' and 'font' parameters have same > subtypes as 'col'. > > >Thanks -- very helpful.