mapview provides a few special popup rendering functions. These can be used to generate:

  • attribute table popups
  • graph popups (i.e. plots in popups)
    • static (ggplot2, lattice, base)
    • interactive (htmlwidgets)
  • image popups

Attribute table popups

popupTable is the standard popup function used in mapview. It provides a static table rendering of all attributes of the individual features.

## The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
## which was just loaded, were retired in October 2023.
## Please refer to R-spatial evolution reports for details, especially
## It may be desirable to make the sf package available;
## package maintainers should consider adding sf to Suggests:.

mapview(breweries, popup = popupTable(breweries,
                                      zcol = c("brewery",

This can also be used with leaflet maps

leaflet() %>%
  addTiles() %>%
  addCircleMarkers(data = breweries,
                   popup = popupTable(breweries))

Graph popups

popupGraph allows us to include static or interactive (htmlwidgets) plots in popups. In the following example we will show a scatterplot of copper ~ cadmium for each individual feature of the famous meuse data set


coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
## Warning in CPL_crs_from_input(x): GDAL Message 1: +init=epsg:XXXX syntax is
## deprecated. It might return a CRS with a non-EPSG compliant axis order.
p <- xyplot(copper ~ cadmium, data = meuse@data, col = "grey", pch = 20, cex = 2)
p <- mget(rep("p", length(meuse)))

clr <- rep("grey", length(meuse))
p <- lapply(1:length(p), function(i) {
  clr[i] <- "red"
  update(p[[i]], col = clr)

        zcol = "cadmium",
        popup = popupGraph(p))