站长工具是做什么的,上海百姓装潢有限公司,开一家公司需要具备什么条件,程序编程软件大家好#xff0c;我是带我去滑雪#xff01; 地图相关图形绘制具有许多优点#xff0c;这些优点使其在各种领域和应用中非常有用。例如#xff1a;地图相关图形提供了一种直观的方式来可视化数据#xff0c;使数据更容易理解和分析。通过地图#xff0c;可以看到数据的空… 大家好我是带我去滑雪 地图相关图形绘制具有许多优点这些优点使其在各种领域和应用中非常有用。例如地图相关图形提供了一种直观的方式来可视化数据使数据更容易理解和分析。通过地图可以看到数据的空间分布识别趋势和模式并从中获取有关地理位置的见解。下面使用R语言绘制地图相关图。
1数据 使用美国50个州2005年的收入分配不均等指数其中的6个收入不均等指数除了泰尔熵指数之外均介于0到1之间数值越大代表收入分配越不均匀。详细数据在文末。
2收入不均等指数数据整理与点状图绘制 library(lattice) ineq50read.csv(ineq50.csv, headerF) names(ineq50)c(ATKIN05,GINI,RMEANDEV,THEIL,TOP1,TOP10) save(ineq50, fileineq50.RData) load(ineq50.RData) attach(ineq50) vncolnames(ineq50) j2 indexineq50[,vn[j]] datadata.frame(name state.name,region state.region,yindex) namestate.name regionstate.region dotplot(reorder(name, index)~index, ineq50, mainc(Inequality Index),xlabvn[j]) 输出结果 通过图像可以发现康涅狄格州的收入分配最不平均西弗吉尼亚州则最好。
3实现切段绘图 b0.9 # Define cutting point cuts shingle(index,intervals rbind(c(0, b),c(b, 2))) dotplot(reorder(name, index) ~ index| cuts , ineq50, strip FALSE, layout c(2, 1), levels.fos 1:50, scales list(x free), between list(x 0.5), xlab Theil income inequality index, par.settings list(layout.widths list(panel c(2, 1)))) 输出结果 4按地理区域呈现收入不均等指数数据 ineq50$regionwith(ineq50, reorder(region, index, median)) ineq50$namewith(ineq50,reorder(reorder(name, index), as.numeric(region))) dotplot(name~ index | region, ineq50, strip F, strip.left T, layout c(1, 4), scales list(y list(relation free)),xlab vn[j]) 输出结果 5在美国地图上呈现收入不均等指数 state.info data.frame(name state.name,long state.center$x,lat state.center$y,yindex) library(maps) state.map map(state, plotFALSE, fill FALSE) panel.3dmap function(..., rot.mat, distance, xlim, ylim, zlim, xlim.scaled, ylim.scaled, zlim.scaled) { scaled.val function(x, original, scaled) { scaled[1] (x - original[1]) * diff(scaled) / diff(original) } m ltransform3dto3d(rbind(scaled.val(state.map$x, xlim, xlim.scaled), scaled.val(state.map$y, ylim, ylim.scaled),zlim.scaled[1]), rot.mat, distance) panel.lines(m[1,], m[2,], col grey76) } cloud(index ~ long lat, state.info, subset !(name %in% c(Alaska, Hawaii)), panel.3d.cloud function(...) { panel.3dmap(...) panel.3dscatter(...) }, type h, scales list(draw FALSE), zoom 1.2,xlim state.map$range[1:2], ylim state.map$range[3:4],xlab NULL, ylab NULL, zlab NULL, aspect c(diff(state.map$range[3:4])/diff(state.map$range[1:2]), 0.3), panel.aspect 0.75, lwd 2, screen list(z 30, x -70), par.settings list(axis.line list(col transparent), box.3d list(col transparent, alpha 0))) 输出结果 可以发现收入分配不均匀的州多集中在美国的东部和西部。
需要数据集的家人们可以去百度网盘永久有效获取
链接https://pan.baidu.com/s/1E59qYZuGhwlrx6gn4JJZTg?pwd2138 提取码2138 更多优质内容持续发布中请移步主页查看。 点赞关注,下次不迷路