axis tick colors: only one value allowed?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

axis tick colors: only one value allowed?

Carl Witthoft
Hi,
So far as I can tell, the 'col.ticks' parameter for axis() only uses the
first value provided.  E.g.:

  plot(0:1,0:1, col.ticks=c('blue','red','green'))  #all ticks are blue

Just wondering if there's a different option in the basic plot commands
that can handle multiple colors, and also whether ggplot and/or lattice
allow for multiple tick colors.

Background: I ran into this limit while trying to colorize the ticks as
plotted by rug() .   There's an easy workaround, as the output of rug()
can be duplicated with something along the lines of

 > points(mydata, rep(0.5, length(mydata)),
col=rainbow(20)[mydata*20/max(mydata)] )

So I can create color rugplots, but do wonder about enhancements to the
plot routines (albeit pretty silly enhancements).

As another side note: calling rug() with color set to '#00000033'  lets
you see dense regions as darker than sparse regions, without having to
resort to calling  jitter() first.


Carl


--

Sent from my Cray XK6
"Pendeo-navem mei anguillae plena est."

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: axis tick colors: only one value allowed?

Hans W Borchers
Carl Witthoft <carl <at> witthoft.com> writes:

>
> Hi,
> So far as I can tell, the 'col.ticks' parameter for axis() only uses the
> first value provided.  E.g.:
>
>   plot(0:1,0:1, col.ticks=c('blue','red','green'))  #all ticks are blue
>
> Just wondering if there's a different option in the basic plot commands
> that can handle multiple colors, and also whether ggplot and/or lattice
> allow for multiple tick colors.

See `?axis' or try this:

    plot(0:1,0:1, type = "n", axes = FALSE)
    box()
    axis(side=1, lwd.ticks = 2, col.ticks="blue")
    axis(side=2, lwd.ticks = 2, col.ticks="red")

>
> [...]
>
> Carl
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: axis tick colors: only one value allowed?

Carl Witthoft
In reply to this post by Carl Witthoft
That only puts different colors on different axes.  I was wondering
about the (silly) possibility of having a range of colors for the ticks
on a given axis.


<quote>
From: Hans W Borchers <hwborchers_at_googlemail.com>
Date: Tue, 13 Dec 2011 14:21:31 +0000
Carl Witthoft <carl <at> witthoft.com> writes:

 >
 > Hi,
 > So far as I can tell, the 'col.ticks' parameter for axis() only uses the
 > first value provided. E.g.:
 >
 > plot(0:1,0:1, col.ticks=c('blue','red','green')) #all ticks are blue
 >
 > Just wondering if there's a different option in the basic plot commands
 > that can handle multiple colors, and also whether ggplot and/or lattice
 > allow for multiple tick colors.
See `?axis' or try this:

     plot(0:1,0:1, type = "n", axes = FALSE)     box()
     axis(side=1, lwd.ticks = 2, col.ticks="blue")     axis(side=2,
lwd.ticks = 2, col.ticks="red")
--

Sent from my Cray XK6
"Pendeo-navem mei anguillae plena est."

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: axis tick colors: only one value allowed?

Peter Ehlers
On 2011-12-14 18:32, Carl Witthoft wrote:
> That only puts different colors on different axes.  I was wondering
> about the (silly) possibility of having a range of colors for the ticks
> on a given axis.
>

I think you would have to either hack the code or issue
several axis() calls, e.g.

   plot(1:9, 1:9, axes=FALSE, frame=TRUE)
   axis(1, at=c(1,4,7), col.ticks=2, lwd.ticks=2)
   axis(1, at=c(2,5,8), col.ticks=3, lwd.ticks=2)
   axis(1, at=c(3,6,9), col.ticks=4, lwd.ticks=2)

Add col.axis=yourColourChoice arguments if you also want
coloured labels.

Peter Ehlers

>
> <quote>
> From: Hans W Borchers<hwborchers_at_googlemail.com>
> Date: Tue, 13 Dec 2011 14:21:31 +0000
> Carl Witthoft<carl<at>  witthoft.com>  writes:
>
>   >
>   >  Hi,
>   >  So far as I can tell, the 'col.ticks' parameter for axis() only uses the
>   >  first value provided. E.g.:
>   >
>   >  plot(0:1,0:1, col.ticks=c('blue','red','green')) #all ticks are blue
>   >
>   >  Just wondering if there's a different option in the basic plot commands
>   >  that can handle multiple colors, and also whether ggplot and/or lattice
>   >  allow for multiple tick colors.
> See `?axis' or try this:
>
>       plot(0:1,0:1, type = "n", axes = FALSE)     box()
>       axis(side=1, lwd.ticks = 2, col.ticks="blue")     axis(side=2,
> lwd.ticks = 2, col.ticks="red")

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.