Comments (5)
Following the WIP of @rCarto , I have been working on further develop a feature like that: https://github.com/dieghernan/cartography/blob/histv2/R/maphist.R
There is still a point on thinking if this needs to be integrated into a legend or if it can live as standalone feature. In case of integration, the problem on legendChoro
is that it doesn't handle real data inputs, just labels, so a call to histogram there would need major changes.
A example on how the WIP compares with tmap
so far:
library(sf)
library(tmap)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package="cartography"))
mtq$chomage=mtq$CHOM/mtq$ACT
cols=carto.pal("wine.pal",4)
# TMAP OPTION--------
tm_shape(mtq) +
tm_borders(col = 'white', lwd = 0.3) +
tm_fill(col = 'chomage', title = 'Chomage', legend.hist = TRUE,
palette = cols) +
tm_legend(legend.outside = TRUE)
# CARTOGRAPHY OPTION--------
par(mar=c(0,0,0,3))
brks=as.double(pretty(mtq$chomage))
choroLayer(mtq,var="chomage", breaks = brks, col=cols,
legend.pos="topright", legend.title.txt="Chomage",
legend.values.rnd=2)
maphist(mtq$chomage,breaks = brks,pos="right", col=cols)
from cartography.
An attempt to integrate it:
library(cartography)
library(sf)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package="cartography"))
# Population density
mtq$POPDENS <- 1e6 * mtq$POP / st_area(x = mtq)
par(mar = c(0.5,0.5,2,0.5))
bks <- getBreaks(mtq$POPDENS, method = "quantile", nclass = 6)
cols <- carto.pal(pal1 = "wine.pal", 6)
choroLayer(x = mtq, var = "POPDENS", breaks = bks, col = cols,
border = NA, legend.title.txt = "Population\nDensity",
legend.hist = TRUE) #NEW PARAMETER
layoutLayer("Testing histogram", theme = "wine.pal")
from cartography.
Hi,
Yes, that would be a nice feature.
I already tried something like that here.
I'm not sure that's the way it should be done in cartography.
from cartography.
WIP here : https://github.com/riatelab/cartography/tree/hist
from cartography.
Hello @dieghernan,
thanks, both solutions look great. However, I agree with you in that the standalone Version seems more felxible. Great job!
from cartography.
Related Issues (20)
- Legend not reflecting breaks when breaks have decimals? HOT 5
- using 'custom' colors? HOT 1
- CRS issues HOT 5
- orphaned hole, cannot find containing polygon HOT 1
- Error in labelLayer when nrow(x) == 1 & overlap = FALSE HOT 1
- New features HOT 6
- Custom Tiles HOT 4
- missing corner case in cartography::getTiles HOT 1
- add more methods to getBreaks HOT 6
- Format legends on layers
- Bug on waffleLayer
- colored pencil maps with r by using HOT 3
- spikeLayer() ? HOT 2
- Facets HOT 2
- Symbols sizes in the legend.
- Add alpha channel to pngs HOT 1
- Can cartography create curved road labels, and loop base maps of different extents? HOT 3
- Please remove dependencies on **rgdal**, **rgeos**, and/or **maptools** HOT 2
- Problème création carte Guadeloupe HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cartography.