在一个州Choropleth地图内的县 [英] Counties within One State Choropleth Map

查看:212
本文介绍了在一个州Choropleth地图内的县的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很努力地定制并找到正确的代码来构建我试图在某个特定状态下由县创建的企业盈利的等值线图。 p>到目前为止我所做的是能够绘制我的代码,尽管我不想要一个调色板,并且打破了也是不可取的。



<$ p
$ b $ library(choroplethr)
library(ggplot2)
$ b县< - data.frame(region = c(19001,19013,19017,19019,19021) ,
value = c(-37102,-41052,35016,-13180,-8062,6357,-46946,-5380))

county_choropleth(county ,Test,state_zoom =iowa)+ scale_fill_brewer(Test,palette =Blues)

我得到这个情节:



理想情况下,我想能够自定义颜色朋友当正面为蓝色时,负面时为红色。另外,在这两种颜色之间创建更多颜色比例的中断也是理想的。我想让休息更愉快的数字,如35,000,0等,而不是$ 35,016,公顷。最后,我想根据FIPS代码将所有北美县都做成灰色或与比例尺不同的颜色。

我没有成功尝试使用scale_colour_gradient命令及其兄弟命令的不同变体。



请让我知道你是否需要任何澄清或更多的代码。感谢您的帮助!

解决方案

您可以尝试

  county_choropleth(county,Test,state_zoom =iowa,num_colors = 1)+ 
scale_fill_gradient2(high =blue,
low =red ,
na.value =grey90,
breaks = pretty(county $ value,n = 10),
label = scales :: dollar_format())


I'm struggling to customize and find the right code to structure the choropleth map that I am attempting to make of profit of a business by county in a specific state.

What I have done so far is be able to plot my code, albeit with a color palette that I don't want and breaks that are undesirable as well.

library(choroplethr)
library(ggplot2)

county <- data.frame(region = c(19001,19013,19017,19019,19021,19023,19033,19035),
                 value=c(-37102,-41052,35016,-13180,-8062,6357,-46946,-5380))

county_choropleth(county, "Test", state_zoom = "iowa") + scale_fill_brewer("Test",palette="Blues")

And I get this plot:

Ideally, I would like to be able to customize the color palette to be blue when positive and red when negative. Also, creating more breaks in the color scale between these 2 colors would be ideal as well. I would like to make the breaks more pleasant numbers such as "35,000", "0", etc. not $35,016, ha. Finally, I would like to make all NA counties, based on FIPS codes, grey or a different color than one that would take place on the scale.

I have unsuccessfully tried to use different variations of the scale_colour_gradient command and its "sibling" commands.

Please, let me know if you need any clarification or more code. Thank you for any and all help!

解决方案

You could try

county_choropleth(county, "Test", state_zoom = "iowa", num_colors = 1) + 
  scale_fill_gradient2(high = "blue", 
                       low = "red", 
                       na.value = "grey90", 
                       breaks = pretty(county$value, n = 10), 
                       label = scales::dollar_format())

这篇关于在一个州Choropleth地图内的县的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆