Comments (6)
@dtkaplan proposed something along the lines of
gf_choropleth(income ~ state, data = Crimes, map = US)
This looks clean, but still leaves some things to be determined:
- What aesthetic is
income
mapped to?
- fill most likely, but at least alpha and fill make sense here. Are we going to force one? Allow either? Have two functions, one for each?
- What data structure is
map
?
- must users come up with a map? are we only supporting certain maps?
- How are
data
andmap
merged?
- presumably there must be a key that is used to merge the data together. how is it specified?
- merging the data can be slow. For repeated maps that differ only in how the data are displayed and not the data themselves, it would be nice to avoid repeatedly doing the merge. Perhaps it is better to think of map creation as a two step process. In step one, the data are prepared and merged. Once that has happened, the plot itself can be created and modified.
income
is not "positional" and so doesn't fit as well with our current formula approach. (At least it is unusual in this regard.)- Given some of the other mapping options out there, is this the best place to devote
ggformula
resources?
from ggformula.
Now that ggplot2
will have geom_sf()
, perhaps we can build gf_sf()
to mimic. Need to explore.
from ggformula.
First attempt is functional. Improvements/examples/documentation may be added/refined later.
library(ggformula)
theme_set(theme_bw())
library(maps)
MI <- sf::st_as_sf(map("county", "michigan", plot = FALSE, fill = TRUE))
gf_sf(fill = ~factor(nchar(ID)), data = MI) %>% gf_refine(coord_sf())
from ggformula.
This is great!
from ggformula.
I concur. But I now worry that the documentation/overview is out of date for both ggformula and mosaic and wonder if a separate issue should be created about how to help instructors get a comprehensive list of the functionality of these packages.
from ggformula.
I've added an example to the vignette.
if (require(maps) && require(mosaic) && require(dplyr) && require(sf) && require(purrr)) {
USshape <-
sf::st_as_sf(maps::map('state', plot = FALSE, fill = TRUE)) %>%
dplyr::mutate(
name_length = nchar(ID),
centroid = purrr::map(geometry, st_centroid),
coords_x = purrr::map_dbl(centroid, 1),
coords_y = purrr::map_dbl(centroid, 2)
)
gf_sf(fill = ~ factor(name_length), color = "white", data = USshape, alpha = 0.5) %>%
gf_sf(data = sf::st_centroid(USshape), color = "white", alpha = 0.5, size = 3) %>%
gf_text(coords_y ~ coords_x, label = ~ ID, color = "gray20", size = 2) %>%
gf_labs(x = "", y = "") %>%
gf_refine(mosaic::theme_map(), theme_bw()) %>%
gf_labs(fill = "name length")
}
Created on 2018-06-01 by the reprex package (v0.2.0).
from ggformula.
Related Issues (20)
- update data sets used in examples HOT 2
- naming in mosaic and ggformula HOT 4
- Add examples showing how to use gf_lm()/gf_smooth() with custom models and backtrans HOT 1
- incorrect y axis label HOT 2
- gf_dist not working as we predict... HOT 3
- Consider redoing using "labelled" data labels in plots. HOT 6
- Chaining a boxplot to a histogram for large data sets HOT 1
- Fix grab_formals() to work with devel version R
- remove strangling ..density.. in gf_dist()
- add support for non-syntactic variable names in formulas HOT 1
- Backticks in variable names HOT 3
- Please remove or change the way you set default alpha in histograms/density plots HOT 7
- migrate from size to linewidth for linelike geoms
- gf_density warning message about underlying ggplot stat(density) HOT 2
- applying a theme HOT 2
- Rain cloud plot HOT 1
- Properly reexporting functions from `labelled` HOT 8
- rename master branch to main
- couldnt update and now cannot reinstall the package HOT 5
- Warning about use of `size` aesthetic HOT 1
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 ggformula.