Map with blank background

Showing 1-5 of 5 messages
Map with blank background Muenchen, Robert A (Bob) 10/31/10 8:43 AM
Hi All,

I'm doing a teaching example of a small choropleth map. I want to remove the axes and the gray background. I've got it working with the code below. Is there an option I'm missing that would make this much easier?

Thanks,
Bob

no_margins <- opts(
 axis.line =         theme_blank(),
 axis.text.x =       theme_blank(),
 axis.text.y =       theme_blank(),
 axis.ticks =        theme_blank(),
 axis.title.x =      theme_blank(),
 axis.title.y =      theme_blank(),
 axis.ticks.length = unit(0, "cm"),
 axis.ticks.margin = unit(0, "cm"),
 panel.background =  theme_blank(),
 panel.border =      theme_blank(),
 panel.grid.major =  theme_blank(),
 panel.grid.minor =  theme_blank(),
 plot.background =   theme_blank(),
 plot.title =        theme_blank(),
 plot.margin =       unit(c(0, 0, 0, 0), "lines")
)  
ggplot(data=TinylandDF)+
  geom_polygon( aes(long, lat,
    fill=pop, group=group) ) +
  geom_text( aes(labptX, labptY, label=region) ) +
  scale_fill_continuous(low = "grey80", high = "grey20") +
  coord_equal() +
  opts(panel.grid.major = theme_blank(),
       panel.grid.minor = theme_blank(),
       panel.background = theme_blank()) +
       no_margins


=========================================================
  Bob Muenchen (pronounced Min'-chen), Manager  
  Research Computing Support
  Voice: (865) 974-5230  
  Email: muen...@utk.edu
  Web:   http://oit.utk.edu/research,
  News:  http://oit.utk.edu/research/news.php
========================================================

Re: Map with blank background Brian Diggs 11/1/10 12:34 PM


On Oct 31, 8:43 am, "Muenchen, Robert A (Bob)" <muenc...@utk.edu>
wrote:
> Hi All,
>
> I'm doing a teaching example of a small choropleth map. I want to remove the axes and the gray background. I've got it working with the code below. Is there an option I'm missing that would make this much easier?

Not that I know of.  There are additional themes in the ggExtra
package, but none so minimal as the one you've created.  You assigned
the opts call to a variable, which at least abstracts that from being
listed in your plot call, which is about as simplified as you can
get.  The only thing to make it simpler is to remove the opts call in
the ggplot call since panel.grid.major, panel.grid.minor, and
panel.background are all already set to theme_blank() in no_margins.
>   Email: muenc...@utk.edu
>   Web:  http://oit.utk.edu/research,
>   News:  http://oit.utk.edu/research/news.php
> ========================================================

--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University
RE: Map with blank background Muenchen, Robert A (Bob) 11/1/10 1:23 PM
Hi Brian,

OK, I'll try that out. Thanks for the help!

Bob

>--
>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

Re: Map with blank background Osmo Salomaa 11/2/10 8:08 AM
For what it's worth, here's the theme I use for making maps. To use
it, just do ggplot(...) + ... + theme_map().

theme_map = function(size=12)
{
    o = list(axis.line=theme_blank(),
             axis.text.x=theme_blank(),
             axis.text.y=theme_blank(),
             axis.ticks=theme_blank(),
             axis.ticks.length=unit(0.3, "lines"),
             axis.ticks.margin=unit(0.5, "lines"),
             axis.title.x=theme_blank(),
             axis.title.y=theme_blank(),
             legend.background=theme_rect(fill="white", colour=NA),
             legend.key=theme_rect(colour="white"),
             legend.key.size=unit(1.2, "lines"),
             legend.position="right",
             legend.text=theme_text(size=size*0.8),
             legend.title=theme_text(size=size*0.8, face="bold",
hjust=0),
             panel.background=theme_blank(),
             panel.border=theme_blank(),
             panel.grid.major=theme_blank(),
             panel.grid.minor=theme_blank(),
             panel.margin=unit(0, "lines"),
             plot.background=theme_blank(),
             plot.margin=unit(c(1, 1, 0.5, 0.5), "lines"),
             plot.title=theme_text(size=size*1.2),
             strip.background=theme_rect(fill="grey90",
colour="grey50"),
             strip.text.x=theme_text(size=size*0.8),
             strip.text.y=theme_text(size=size*0.8, angle=-90))

    return(structure(o, class="options"))
}
RE: Map with blank background Muenchen, Robert A (Bob) 11/3/10 8:29 AM
I'll give that a try. Thanks! -Bob

>-----Original Message-----
>From: ggp...@googlegroups.com [mailto:ggp...@googlegroups.com] On
>Behalf Of Osmo Salomaa
>Sent: Tuesday, November 02, 2010 11:08 AM
>To: ggplot2
>Subject: Re: Map with blank background
>
>--
>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