r - ggplot2 following layer removing previous layer -
when add layer ggplot graph, previous layer settings disappear. keep size of chart points, when add layer change background of plot, point sizes removed.
code plot:
p <- ggplot(a,aes(zip, perc)) + geom_point() p <- p + labs(x = "zip code", y = "percent penetration") + labs(title = "zip code tier a") p + geom_point(aes(size = zgrp)) p + theme(panel.background = element_rect(fill = "ivory"))
data:
zip cgrp zgrp perc 1: 12007 4 15 48.387097 2: 12008 4 25 41.666667 3: 12009 4 956 52.643172 4: 12010 4 1047 30.025810 5: 12018 4 859 49.113779 6: 12019 4 838 54.380273 7: 12020 4 1233 43.126967 8: 12022 4 37 34.579439 9: 12023 4 225 47.669492 10: 12027 4 139 50.180505 11: 12028 4 35 46.052632 12: 12033 4 1062 48.559671 13: 12041 4 47 42.342342 14: 12046 4 55 43.650794 15: 12047 4 1282 36.807350 16: 12052 4 118 45.914397 17: 12053 4 362 49.118046 18: 12054 4 1818 59.743674 19: 12055 4 2 50.000000 20: 12056 4 117 45.703125 21: 12057 4 9 19.565217 22: 12059 4 198 55.153203 23: 12061 4 1239 53.084833 24: 12062 4 176 41.805226 25: 12065 4 2829 48.483290 26: 12066 4 101 46.976744 27: 12067 4 156 45.086705 28: 12074 4 105 47.085202 29: 12077 4 644 57.295374 30: 12083 4 144 43.243243 31: 12084 4 328 43.328930 32: 12090 4 121 41.296928 33: 12094 4 136 38.746439 34: 12110 4 1703 49.219653 35: 12118 4 830 38.712687 36: 12120 4 21 39.622642 37: 12121 4 155 52.364865 38: 12122 4 90 32.490975 39: 12123 4 564 43.251534 40: 12130 4 86 42.156863 41: 12134 4 62 43.055556 42: 12137 4 92 42.396313 43: 12138 4 161 42.368421 44: 12140 4 173 51.335312 45: 12143 4 364 37.371663 46: 12144 4 2172 38.903815 47: 12147 4 32 48.484848 48: 12148 4 279 61.184211 49: 12150 4 38 40.000000 50: 12151 4 47 52.808989 51: 12153 4 115 63.535912 52: 12154 4 161 43.869210 53: 12156 4 97 48.743719 54: 12158 4 621 44.230769 55: 12159 4 861 63.636364 56: 12168 4 118 51.754386 57: 12169 4 19 35.185185 58: 12180 4 3095 31.630046 59: 12182 4 762 31.500620 60: 12183 4 113 23.541667 61: 12185 4 118 44.528302 62: 12186 4 738 57.927786 63: 12189 4 1122 32.682785 64: 12193 4 148 40.326975 65: 12196 4 370 53.237410 66: 12198 4 801 48.871263 67: 12202 4 301 10.591133 68: 12203 4 2542 45.950832 69: 12204 4 474 26.779661 70: 12205 4 2483 42.928769 71: 12206 4 543 14.056433 72: 12207 4 41 10.049020 73: 12208 4 1693 38.600091 74: 12209 4 763 27.785870 75: 12210 4 469 19.380165 76: 12211 4 1028 57.174638 77: 12302 4 1140 44.618395 78: 12303 4 1850 41.931097 79: 12304 4 938 26.370537 80: 12305 4 98 12.911726 81: 12306 4 1140 37.475345 82: 12307 4 68 4.822695 83: 12308 4 346 17.918177 84: 12309 4 1776 51.270208 85: 12469 4 16 37.209302
Comments
Post a Comment