Cannot plot binded data frames

18 views
Skip to first unread message

Manuel Spínola

unread,
Sep 4, 2016, 11:18:53 AM9/4/16
to ggplot2
Dear list members,

I have 2 data frames resulted of fortifying 2 rasters (RStoolbox::fortify.raster).

rt06df and rt07df

> str(rt06df)
'data.frame': 13056 obs. of  4 variables:
 $ x    : num  -85.3 -85.3 -85.3 -85.3 -85.3 ...
 $ y    : num  9.79 9.79 9.79 9.79 9.79 ...
 $ layer: num  NA NA NA NA NA NA NA NA NA NA ...
 $ tag  : chr  "T06" "T06" "T06" "T06" ...

> str(rt07df)
'data.frame': 9434 obs. of  4 variables:
 $ x    : num  -85.3 -85.3 -85.3 -85.3 -85.3 ...
 $ y    : num  9.79 9.79 9.79 9.79 9.79 ...
 $ layer: num  NA NA NA NA NA NA NA NA NA NA ...
 $ tag  : chr  "T07" "T07" "T07" "T07" ...

When I plot the each data frame there is no problem.

ggplot() + geom_tile(aes(x = x, y = y, fill = layer), data = rt06df) + scale_fill_gradient(guide = FALSE, low = "yellow", high = "red", na.value="transparent")


ggplot() + geom_tile(aes(x = x, y = y, fill = layer), data = rt07df) + scale_fill_gradient(guide = FALSE, low = "yellow", high = "red", na.value="transparent")

but when I try to plot the 2 data frames after binding them with rbind or rbind.fill my plot is empty.

> rtiburon = rbind(rt06df, rt07df)

> str(rtiburon)
'data.frame': 22490 obs. of  4 variables:
 $ x    : num  -85.3 -85.3 -85.3 -85.3 -85.3 ...
 $ y    : num  9.79 9.79 9.79 9.79 9.79 ...
 $ layer: num  NA NA NA NA NA NA NA NA NA NA ...
 $ tag  : chr  "T06" "T06" "T06" "T06" ...

> ggplot() + geom_tile(aes(x = x, y = y, fill = layer), data = rtiburon) + scale_fill_gradient(guide = FALSE, low = "yellow", high = "red", na.value="transparent")

I don't understand why I cannot plot the binded data frame.  

--
Manuel Spínola, Ph.D.
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspi...@una.cr
mspin...@gmail.com
Teléfono: (506) 8706 - 4662
Personal website: Lobito de río
Institutional website: ICOMVIS

Brian

unread,
Sep 4, 2016, 1:49:44 PM9/4/16
to Manuel Spínola, ggplot2
Hi Manuel,
could you please provide the error message?
You may try updating your r-packages.
Cheers
> *Manuel Spínola, Ph.D.*
> Instituto Internacional en Conservación y Manejo de Vida Silvestre
> Universidad Nacional
> Apartado 1350-3000
> Heredia
> COSTA RICA
> mspi...@una.cr <mailto:mspi...@una.ac.cr>
> mspin...@gmail.com <mailto:mspin...@gmail.com>
> Teléfono: (506) 8706 - 4662
> Personal website: Lobito de río
> <https://sites.google.com/site/lobitoderio/>
> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
>
> --
> --
> You received this message because you are subscribed to the ggplot2
> mailing list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google
> Groups "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ggplot2+u...@googlegroups.com
> <mailto:ggplot2+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Manuel Spínola

unread,
Sep 4, 2016, 3:50:03 PM9/4/16
to Brian, ggplot2
Hi Brian,

No error message, just an empty plot with the classical ggplot2 theme.

Manuel




More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google
Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send

For more options, visit https://groups.google.com/d/optout.



--
Manuel Spínola, Ph.D.
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspi...@una.cr
mspin...@gmail.com
Teléfono: (506) 8706 - 4662
Personal website: Lobito de río
Institutional website: ICOMVIS

Brian

unread,
Sep 4, 2016, 5:11:46 PM9/4/16
to Manuel Spínola, ggplot2
Uh huh. Do the to maps overlap and "transparent" themselves out?

If so, what if you combine the two properly?

On 09/04/2016 09:49 PM, Manuel Spínola wrote:
> Hi Brian,
>
> No error message, just an empty plot with the classical ggplot2 theme.
>
> Manuel
>
>
>
> 2016-09-04 11:49 GMT-06:00 Brian <zenl...@gmail.com
> <mailto:zenl...@gmail.com>>:
> mspi...@una.cr <mailto:mspi...@una.cr>
> <mailto:mspi...@una.ac.cr <mailto:mspi...@una.ac.cr>>
> mspin...@gmail.com <mailto:mspin...@gmail.com>
> <mailto:mspin...@gmail.com <mailto:mspin...@gmail.com>>
> Teléfono: (506) 8706 - 4662
> Personal website: Lobito de río
> <https://sites.google.com/site/lobitoderio/
> <https://sites.google.com/site/lobitoderio/>>
> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
>
> --
> --
> You received this message because you are subscribed to the ggplot2
> mailing list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
> <https://github.com/hadley/devtools/wiki/Reproducibility>
>
> To post: email ggp...@googlegroups.com
> <mailto:ggp...@googlegroups.com>
> To unsubscribe: email ggplot2+u...@googlegroups.com
> <mailto:ggplot2%2Bunsu...@googlegroups.com>
> More options: http://groups.google.com/group/ggplot2
> <http://groups.google.com/group/ggplot2>
>
> ---
> You received this message because you are subscribed to the Google
> Groups "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from
> it, send
> an email to ggplot2+u...@googlegroups.com
> <mailto:ggplot2%2Bunsu...@googlegroups.com>
> <mailto:ggplot2+u...@googlegroups.com
> <mailto:ggplot2%2Bunsu...@googlegroups.com>>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.

Manuel Spínola

unread,
Sep 4, 2016, 6:07:56 PM9/4/16
to Brian, ggplot2
I tried using facet_wrap(~ tag) but I obtain two empty plots.

Manuel

        <mailto:ggplot2@googlegroups.com>
        To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
        <mailto:ggplot2%2Bunsubscribe@googlegroups.com>
        More options: http://groups.google.com/group/ggplot2

        <http://groups.google.com/group/ggplot2>

        ---
        You received this message because you are subscribed to the Google
        Groups "ggplot2" group.
        To unsubscribe from this group and stop receiving emails from
        it, send

        For more options, visit https://groups.google.com/d/optout
        <https://groups.google.com/d/optout>.




--
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspi...@una.cr <mailto:mspi...@una.ac.cr>
mspin...@gmail.com <mailto:mspin...@gmail.com>
Teléfono: (506) 8706 - 4662
Personal website: Lobito de río
<https://sites.google.com/site/lobitoderio/>
Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>



--
Manuel Spínola, Ph.D.
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspi...@una.cr
mspin...@gmail.com
Teléfono: (506) 8706 - 4662
Personal website: Lobito de río
Institutional website: ICOMVIS
Reply all
Reply to author
Forward
0 new messages