Adding Horizontal Lines to Image/Tile plot

1,028 views
Skip to first unread message

Andrew Redd

unread,
Feb 8, 2011, 12:51:13 PM2/8/11
to ggplot2
I've attached a pdf of a tile plot that I am using to help check for problems in an algorithm.  What would help would be to add horizontal lines, and only horizontal lines to the plot to separate the rows.  Is there an easy way to do this?  The plot was created with

qplot(melt(rows), x=X1, y=X2, fill=value, geom="tile")

The principle is the same regardless of the underlying data so if you need a working example from the package documentation should work.

ggplot(mtcars, aes(y=factor(cyl), x=mpg)) + stat_bin(aes(fill=..count..), geom="tile", binwidth=3, position="identity")

Thanks,
Andrew
5621b2f135bb2d162579681100fe6060.pdf

Andrew Redd

unread,
Feb 8, 2011, 1:11:14 PM2/8/11
to Adam_L...@keybank.com, ggplot2
Thank you all,
Both solutions give horizontal lines through the middle of the tiles, and what I want is at the edge of the tiles.  This is more what I was thinking, but it a little ugly.  I thought that there might be a theme setting or something else handy.  All told it gets me what I wanted.

ggplot(mtcars, aes(y=factor(cyl), x=mpg)) + stat_bin(aes(fill=..count..), geom="tile", binwidth=3, position="identity")+
geom_hline(aes(yintercept=c(as.numeric(factor(cyl))+.5,.5))) 

Thanks,
Andrew

On Tue, Feb 8, 2011 at 10:56 AM, <Adam_L...@keybank.com> wrote:

ggplot(mtcars, aes(y=factor(cyl), x=mpg)) + stat_bin(aes(fill=..count..), geom="tile", binwidth=3, position="identity")+geom_hline(aes(yintercept=factor(cyl)))


Adam Loveland





Andrew Redd <amr...@gmail.com>
Sent by: ggp...@googlegroups.com

02/08/2011 12:51 PM

To
ggplot2 <ggp...@googlegroups.com>
cc
Subject
Adding Horizontal Lines to Image/Tile plot


--

You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example:
http://gist.github.com/270442


To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options:
http://groups.google.com/group/ggplot2[attachment "5621b2f135bb2d162579681100fe6060.pdf" deleted by Adam Loveland/GL/KB/KeyCorp]



This communication may contain privileged and/or confidential information. It
is intended solely for the use of the addressee. If you are not the intended
recipient, you are strictly prohibited from disclosing, copying, distributing
or using any of this information. If you received this communication in error,
please contact the sender immediately and destroy the material in its entirety,
whether electronic or hard copy. This communication may contain nonpublic personal
information about consumers subject to the restrictions of the 
Gramm-Leach-Bliley Act. You may not directly or indirectly reuse or redisclose
such information for any purpose other than to provide the services for which
you are receiving the information.

127 Public Square, Cleveland, OH 44114



If you prefer not to receive future e-mail offers for products or services from Key
send an e-mail to mailto:DNERe...@key.com with 'No Promotional E-mails' in the
SUBJECT line.


Adam_L...@keybank.com

unread,
Feb 8, 2011, 12:56:16 PM2/8/11
to Andrew Redd, ggplot2

ggplot(mtcars, aes(y=factor(cyl), x=mpg)) + stat_bin(aes(fill=..count..), geom="tile", binwidth=3, position="identity")+geom_hline(aes(yintercept=factor(cyl)))


Adam Loveland





Andrew Redd <amr...@gmail.com>
Sent by: ggp...@googlegroups.com

02/08/2011 12:51 PM

To
ggplot2 <ggp...@googlegroups.com>
cc
Subject
Adding Horizontal Lines to Image/Tile plot





--

You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example:

http://gist.github.com/270442

Reply all
Reply to author
Forward
0 new messages