[R-sig-Geo] Avoid axis labels, ticks and marks in ggRGB() plot
Agustin Lobo
alobolistas at gmail.com
Mon Mar 13 14:25:32 CET 2017
Yes! Thanks!
I knew there had to be a better way. For my set of plots I can set
t <- theme(
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank())
and then
ggRGB(rlogo, r=1, g=2, b=3) + t +ggtitle("patatin")
Agus
On Mon, Mar 13, 2017 at 2:05 PM, Benjamin Leutner
<benjamin.leutner at uni-wuerzburg.de> wrote:
> The problem with your first approach is that there is no "data layer" which
> could span the coordinate axes.
> Since ggRGB by default uses an annotation_raster() in order to keep your
> "fill" dimension free for other data, the coordinate limits are empty,
> hence the plotted raster is lost in the dimensionless void and you get see
> nothing ;-)
>
> I would recommend to start your plot with ggRGB like this:
>
> ggRGB(rlogo, r=1, g=2, b=3) +
> theme(
> axis.text = element_blank(),
> axis.ticks = element_blank(),
> axis.title = element_blank())
>
>
> If you do want to use it with ggLayer = TRUE, there should be at least one
> "geom" with actual data in it (or you'd have to set ggRGB(...,
> geom_raster=TRUE), but I don't see any benefit in that and it would give you
> a huge legend with one entry per rgb color...)
>
> best,
> Benjamin
>
>
> On 03/13/2017 12:10 PM, Agustin Lobo wrote:
>>
>> In order to save space, I prefer to avoid coordinates in the plot
>> generated by ggRGB. Is there any way? I've tried:
>>
>> ggplot() +
>> ggRGB(rlogo, r=1, g=2, b=3,ggLayer=TRUE) +
>> theme(
>> axis.text = element_blank(),
>> axis.ticks = element_blank(),
>> axis.title = element_blank())
>>
>> but get an empty plot.
>> I can circumvent the problem as follows, but it is kind of ugly and
>> complicated,
>> there must be another way:
>>
>> a <- as(extent(rlogo), 'SpatialPolygons')
>> y <- fortify(a,region=id)
>> ggplot(data=y,aes(y=lat, x=long)) +
>> ggRGB(rlogo, r=1, g=2, b=3,ggLayer=TRUE) +
>> geom_polygon(colour="yellow", fill=NA) +
>> guides(fill=FALSE) +
>> coord_fixed(ratio=1) +
>> theme(
>> axis.text = element_blank(),
>> axis.ticks = element_blank(),
>> axis.title = element_blank())
>>
>> Agus
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> --
> Benjamin Leutner M.Sc.
> PhD candidate
>
> Department of Remote Sensing
> University of Wuerzburg
> Campus Hubland Nord 86
> 97074 Wuerzburg, Germany
>
> Tel: +49-(0)931-31 89594
> Fax: +49-(0)931-31 89594-0
> Email: benjamin.leutner at uni-wuerzburg.de
> Web: http://www.fernerkundung.uni-wuerzburg.de
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list