trulia / choroplethr

choroplethr simplifies the creation of choropleths (thematic maps) in R
Other
141 stars 51 forks source link

state_choropleth #30

Closed ksak3 closed 9 years ago

ksak3 commented 9 years ago

I love this function as it was unbelievable easy to create a map... but, how can I generate a map w/o labels? The map is otherwise beautiful but on my screen the labels are large, ugly, and overlap each other in the NE states, and thus are unsuited for publication. Please reconsider this default and/or enable a switch. Thanks!

data(df_pop_state) state_choropleth(df_pop_state, title="US 2012 State Population Estimates", legend="Population", buckets=1)

arilamstein commented 9 years ago

Thank you for using choroplethr and taking the time to report this issue. This feature is indeed available in choroplethr. It is just not available as a parameter in the state_choropleth function. Instead you will need to create a StateChoropleth object as described in the last example of the State Choropleth vignette:

http://cran.r-project.org/web/packages/choroplethr/vignettes/b-state-choropleth.html

Here is the code you need:

library(choroplethr) 
data(df_pop_state)

choro = StateChoropleth$new(df_pop_state)
choro$show_labels=FALSE
choro$render()

In previous versions of choroplethr show_labels was a parameter to the function. But I found that the parameter count was just getting unwiedly and so iin version 2.0 I decided to make all the convenience functions (state_choropleth, county_choropleth, etc.) have the exact same, minimal parameters: df, title = "", legend = "", buckets = 7, zoom = NULL.

I haven't found a good way to document all the options on the R6 objects themselves. (And that might be an R6 issue more than a choroplethr issue). So I just pointed people towards the objects in the vignettes and hope that that starts the process.

Thanks again for using the package.

ksak3 commented 9 years ago

Awesome, thanks. FWIW I really did spend some time trying to figure this out! Need one more thing to get the equivalent graph though: choro$set_buckets(1). So much to learn still..