Overlaid_Graphs.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. ---
  2. redirect_from:
  3. - "/chapters/07/3/overlaid-graphs"
  4. interact_link: content/chapters/07/3/Overlaid_Graphs.ipynb
  5. kernel_name: python3
  6. has_widgets: false
  7. title: |-
  8. Overlaid Graphs
  9. prev_page:
  10. url: /chapters/07/2/Visualizing_Numerical_Distributions.html
  11. title: |-
  12. Numerical Distributions
  13. next_page:
  14. url: /chapters/08/Functions_and_Tables.html
  15. title: |-
  16. Functions and Tables
  17. comment: "***PROGRAMMATICALLY GENERATED, DO NOT EDIT. SEE ORIGINAL FILES IN /content***"
  18. ---
  19. <div class="jb_cell tag_remove_input">
  20. <div class="cell border-box-sizing code_cell rendered">
  21. </div>
  22. </div>
  23. <div class="jb_cell">
  24. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  25. <div class="text_cell_render border-box-sizing rendered_html">
  26. <h3 id="Overlaid-Graphs">Overlaid Graphs<a class="anchor-link" href="#Overlaid-Graphs"> </a></h3><p>In this chapter, we have learned how to visualize data by drawing graphs. A common use of such visualizations is to compare two datasets. In this section, we will see how to <em>overlay</em> plots, that is, draw them in a single graphic on a common pair of axes.</p>
  27. <p>For the overlay to make sense, the graphs that are being overlaid must represent the same variables and be measured in the same units.</p>
  28. <p>To draw overlaid graphs, the methods <code>scatter</code>, <code>plot</code>, and <code>barh</code> can all be called in the same way. For <code>scatter</code> and <code>plot</code>, one column must serve as the common horizontal axis for all the overlaid graphs. For <code>barh</code>, one column must serve as the common axis which is the set of categories. The general call looks like:</p>
  29. <p><code>name_of_table.method(column_label_of_common_axis, array_of_labels_of_variables_to_plot)</code></p>
  30. <p>More commonly, we will first select only the columns needed for our graph, and then call the method by just specifying the variable on the common axis:</p>
  31. <p><code>name_of_table.method(column_label_of_common_axis)</code></p>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="jb_cell">
  37. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  38. <div class="text_cell_render border-box-sizing rendered_html">
  39. <h3 id="Scatter-Plots">Scatter Plots<a class="anchor-link" href="#Scatter-Plots"> </a></h3><p><a href="https://en.wikipedia.org/wiki/Francis_Galton">Franics Galton</a> (1822-1911) was an English polymath who was a pioneer in the analysis of relations between numerical variables. He was particularly interested in the controversial area of eugenics – indeed, he coined that term – which involves understading how physical traits are passed down from one generation to the next.</p>
  40. <p>Galton meticulously collected copious amounts of data, some of which we will analyze in this course. Here is a subset of Galton's data on heights of parents and their children. Specifically, the population consists of 179 men who were the first-born in their families. The data are their own heights and the heights of their parents. All heights were measured in inches.</p>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="jb_cell">
  46. <div class="cell border-box-sizing code_cell rendered">
  47. <div class="input">
  48. <div class="inner_cell">
  49. <div class="input_area">
  50. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">heights</span> <span class="o">=</span> <span class="n">Table</span><span class="o">.</span><span class="n">read_table</span><span class="p">(</span><span class="n">path_data</span> <span class="o">+</span> <span class="s1">&#39;galton_subset.csv&#39;</span><span class="p">)</span>
  51. <span class="n">heights</span>
  52. </pre></div>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="output_wrapper">
  57. <div class="output">
  58. <div class="jb_output_wrapper }}">
  59. <div class="output_area">
  60. <div class="output_html rendered_html output_subarea output_execute_result">
  61. <table border="1" class="dataframe">
  62. <thead>
  63. <tr>
  64. <th>father</th> <th>mother</th> <th>son</th>
  65. </tr>
  66. </thead>
  67. <tbody>
  68. <tr>
  69. <td>78.5 </td> <td>67 </td> <td>73.2</td>
  70. </tr>
  71. <tr>
  72. <td>75.5 </td> <td>66.5 </td> <td>73.5</td>
  73. </tr>
  74. <tr>
  75. <td>75 </td> <td>64 </td> <td>71 </td>
  76. </tr>
  77. <tr>
  78. <td>75 </td> <td>64 </td> <td>70.5</td>
  79. </tr>
  80. <tr>
  81. <td>75 </td> <td>58.5 </td> <td>72 </td>
  82. </tr>
  83. <tr>
  84. <td>74 </td> <td>68 </td> <td>76.5</td>
  85. </tr>
  86. <tr>
  87. <td>74 </td> <td>62 </td> <td>74 </td>
  88. </tr>
  89. <tr>
  90. <td>73 </td> <td>67 </td> <td>71 </td>
  91. </tr>
  92. <tr>
  93. <td>73 </td> <td>67 </td> <td>68 </td>
  94. </tr>
  95. <tr>
  96. <td>73 </td> <td>66.5 </td> <td>71 </td>
  97. </tr>
  98. </tbody>
  99. </table>
  100. <p>... (169 rows omitted)</p>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="jb_cell">
  109. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  110. <div class="text_cell_render border-box-sizing rendered_html">
  111. <p>The <code>scatter</code> method allows us to visualize how the sons' heights are related to the heights of both their parents. In the graph, the sons' heights will form the common horizontal axis.</p>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="jb_cell">
  117. <div class="cell border-box-sizing code_cell rendered">
  118. <div class="input">
  119. <div class="inner_cell">
  120. <div class="input_area">
  121. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">heights</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="s1">&#39;son&#39;</span><span class="p">)</span>
  122. </pre></div>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="output_wrapper">
  127. <div class="output">
  128. <div class="jb_output_wrapper }}">
  129. <div class="output_area">
  130. <div class="output_png output_subarea ">
  131. <img src="../../../images/chapters/07/3/Overlaid_Graphs_5_0.png"
  132. >
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. <div class="jb_cell">
  141. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  142. <div class="text_cell_render border-box-sizing rendered_html">
  143. <p>Notice how we only specified the variable (sons' heights) on the common horizontal axis. Python drew two scatter plots: one each for the relation between this variable and the other two.</p>
  144. <p>Both the gold and the blue scatter plots slope upwards and show a positive association between the sons' heights and the heights of both their parents. The blue (fathers) plot is in general higher than the gold, because the fathers were in general taller than the mothers.</p>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="jb_cell">
  150. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  151. <div class="text_cell_render border-box-sizing rendered_html">
  152. <h3 id="Line-Plots">Line Plots<a class="anchor-link" href="#Line-Plots"> </a></h3><p>Our next example involves data on children of more recent times. We will return to the Census data table <code>us_pop</code>, created below again for reference. From this, we will extract the counts of all children in each of the age categories 0 through 18 years.</p>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. <div class="jb_cell">
  158. <div class="cell border-box-sizing code_cell rendered">
  159. <div class="input">
  160. <div class="inner_cell">
  161. <div class="input_area">
  162. <div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># Read the full Census table</span>
  163. <span class="n">census_url</span> <span class="o">=</span> <span class="s1">&#39;http://www2.census.gov/programs-surveys/popest/datasets/2010-2015/national/asrh/nc-est2015-agesex-res.csv&#39;</span>
  164. <span class="n">full_census_table</span> <span class="o">=</span> <span class="n">Table</span><span class="o">.</span><span class="n">read_table</span><span class="p">(</span><span class="n">census_url</span><span class="p">)</span>
  165. <span class="c1"># Select columns from the full table and relabel some of them</span>
  166. <span class="n">partial_census_table</span> <span class="o">=</span> <span class="n">full_census_table</span><span class="o">.</span><span class="n">select</span><span class="p">([</span><span class="s1">&#39;SEX&#39;</span><span class="p">,</span> <span class="s1">&#39;AGE&#39;</span><span class="p">,</span> <span class="s1">&#39;POPESTIMATE2010&#39;</span><span class="p">,</span> <span class="s1">&#39;POPESTIMATE2014&#39;</span><span class="p">])</span>
  167. <span class="n">us_pop</span> <span class="o">=</span> <span class="n">partial_census_table</span><span class="o">.</span><span class="n">relabeled</span><span class="p">(</span><span class="s1">&#39;POPESTIMATE2010&#39;</span><span class="p">,</span> <span class="s1">&#39;2010&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">relabeled</span><span class="p">(</span><span class="s1">&#39;POPESTIMATE2014&#39;</span><span class="p">,</span> <span class="s1">&#39;2014&#39;</span><span class="p">)</span>
  168. <span class="c1"># Access the rows corresponding to all children, ages 0-18</span>
  169. <span class="n">children</span> <span class="o">=</span> <span class="n">us_pop</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="s1">&#39;SEX&#39;</span><span class="p">,</span> <span class="n">are</span><span class="o">.</span><span class="n">equal_to</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="s1">&#39;AGE&#39;</span><span class="p">,</span> <span class="n">are</span><span class="o">.</span><span class="n">below</span><span class="p">(</span><span class="mi">19</span><span class="p">))</span><span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="s1">&#39;SEX&#39;</span><span class="p">)</span>
  170. <span class="n">children</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
  171. </pre></div>
  172. </div>
  173. </div>
  174. </div>
  175. <div class="output_wrapper">
  176. <div class="output">
  177. <div class="jb_output_wrapper }}">
  178. <div class="output_area">
  179. <div class="output_html rendered_html output_subarea ">
  180. <table border="1" class="dataframe">
  181. <thead>
  182. <tr>
  183. <th>AGE</th> <th>2010</th> <th>2014</th>
  184. </tr>
  185. </thead>
  186. <tbody>
  187. <tr>
  188. <td>0 </td> <td>3951330</td> <td>3949775</td>
  189. </tr>
  190. <tr>
  191. <td>1 </td> <td>3957888</td> <td>3949776</td>
  192. </tr>
  193. <tr>
  194. <td>2 </td> <td>4090862</td> <td>3959664</td>
  195. </tr>
  196. <tr>
  197. <td>3 </td> <td>4111920</td> <td>4007079</td>
  198. </tr>
  199. <tr>
  200. <td>4 </td> <td>4077551</td> <td>4005716</td>
  201. </tr>
  202. <tr>
  203. <td>5 </td> <td>4064653</td> <td>4006900</td>
  204. </tr>
  205. <tr>
  206. <td>6 </td> <td>4073013</td> <td>4135930</td>
  207. </tr>
  208. <tr>
  209. <td>7 </td> <td>4043046</td> <td>4155326</td>
  210. </tr>
  211. <tr>
  212. <td>8 </td> <td>4025604</td> <td>4120903</td>
  213. </tr>
  214. <tr>
  215. <td>9 </td> <td>4125415</td> <td>4108349</td>
  216. </tr>
  217. <tr>
  218. <td>10 </td> <td>4187062</td> <td>4116942</td>
  219. </tr>
  220. <tr>
  221. <td>11 </td> <td>4115511</td> <td>4087402</td>
  222. </tr>
  223. <tr>
  224. <td>12 </td> <td>4113279</td> <td>4070682</td>
  225. </tr>
  226. <tr>
  227. <td>13 </td> <td>4119666</td> <td>4171030</td>
  228. </tr>
  229. <tr>
  230. <td>14 </td> <td>4145614</td> <td>4233839</td>
  231. </tr>
  232. <tr>
  233. <td>15 </td> <td>4231002</td> <td>4164796</td>
  234. </tr>
  235. <tr>
  236. <td>16 </td> <td>4313252</td> <td>4168559</td>
  237. </tr>
  238. <tr>
  239. <td>17 </td> <td>4376367</td> <td>4186513</td>
  240. </tr>
  241. <tr>
  242. <td>18 </td> <td>4491005</td> <td>4227920</td>
  243. </tr>
  244. </tbody>
  245. </table>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. </div>
  252. </div>
  253. <div class="jb_cell">
  254. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  255. <div class="text_cell_render border-box-sizing rendered_html">
  256. <p>We can now draw two overlaid line plots, showing the numbers of children in the different age groups for each of the years 2010 and 2014. The method call is analogous to the <code>scatter</code> call in the previous example.</p>
  257. </div>
  258. </div>
  259. </div>
  260. </div>
  261. <div class="jb_cell">
  262. <div class="cell border-box-sizing code_cell rendered">
  263. <div class="input">
  264. <div class="inner_cell">
  265. <div class="input_area">
  266. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">children</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="s1">&#39;AGE&#39;</span><span class="p">)</span>
  267. </pre></div>
  268. </div>
  269. </div>
  270. </div>
  271. <div class="output_wrapper">
  272. <div class="output">
  273. <div class="jb_output_wrapper }}">
  274. <div class="output_area">
  275. <div class="output_png output_subarea ">
  276. <img src="../../../images/chapters/07/3/Overlaid_Graphs_10_0.png"
  277. >
  278. </div>
  279. </div>
  280. </div>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. <div class="jb_cell">
  286. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  287. <div class="text_cell_render border-box-sizing rendered_html">
  288. <p>On this scale, it's important to remember that we only have data at ages 0, 1, 2, and so on; the graphs "join the dots" in between.</p>
  289. <p>The graphs cross each other in a few places: for example, there were more 4-year-olds in 2010 than in 2014, and there were more 14-year-olds in 2014 than in 2010.</p>
  290. <p>Of course, the 14-year-olds in 2014 mostly consist of the 10-year-olds in 2010. To see this, look at the gold graph at <code>AGE</code> 14 and the blue graph at <code>AGE</code> 10. Indeed, you will notice that the entire gold graph (2014) looks like the blue graph (2010) slid over to the right by 4 years. The slide is accompanied by a slight rise due to the net effect of children who entered the country between 2010 and 2014 outnumbering those who left. Fortunately at these ages there is not much loss of life.</p>
  291. </div>
  292. </div>
  293. </div>
  294. </div>
  295. <div class="jb_cell">
  296. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  297. <div class="text_cell_render border-box-sizing rendered_html">
  298. <h3 id="Bar-Charts">Bar Charts<a class="anchor-link" href="#Bar-Charts"> </a></h3><p>For our final example of this section, we look at distributions of ethnicities of adults and children in California as well as in the entire United States.</p>
  299. <p>The Kaiser Family Foundation has complied Census data on the distribution of race and ethnicity in the U.S. The Foundation's website provides compilations of data for <a href="http://kff.org/other/state-indicator/distribution-by-raceethnicity/">the entire U.S. population</a> in 2014, as well as for <a href="http://kff.org/other/state-indicator/children-by-raceethnicity/">U.S. children</a> who were younger than 18 years old that year.</p>
  300. <p>Here is a table adapted from their data for the United States and California. The columns represent everyone in the U.S.A., everyone in California, children in the U.S.A., and children in California. The body of the table contains proportions in the different categories. Each column shows the distribution of ethnicities in the group of people corresponding to that column. So in each column, the entries add up to 1.</p>
  301. </div>
  302. </div>
  303. </div>
  304. </div>
  305. <div class="jb_cell">
  306. <div class="cell border-box-sizing code_cell rendered">
  307. <div class="input">
  308. <div class="inner_cell">
  309. <div class="input_area">
  310. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">usa_ca</span> <span class="o">=</span> <span class="n">Table</span><span class="o">.</span><span class="n">read_table</span><span class="p">(</span><span class="n">path_data</span> <span class="o">+</span> <span class="s1">&#39;usa_ca_2014.csv&#39;</span><span class="p">)</span>
  311. <span class="n">usa_ca</span>
  312. </pre></div>
  313. </div>
  314. </div>
  315. </div>
  316. <div class="output_wrapper">
  317. <div class="output">
  318. <div class="jb_output_wrapper }}">
  319. <div class="output_area">
  320. <div class="output_html rendered_html output_subarea output_execute_result">
  321. <table border="1" class="dataframe">
  322. <thead>
  323. <tr>
  324. <th>Ethnicity</th> <th>USA All</th> <th>CA All</th> <th>USA Children</th> <th>CA Children</th>
  325. </tr>
  326. </thead>
  327. <tbody>
  328. <tr>
  329. <td>Black </td> <td>0.12 </td> <td>0.05 </td> <td>0.14 </td> <td>0.05 </td>
  330. </tr>
  331. <tr>
  332. <td>Hispanic </td> <td>0.18 </td> <td>0.38 </td> <td>0.24 </td> <td>0.5 </td>
  333. </tr>
  334. <tr>
  335. <td>White </td> <td>0.62 </td> <td>0.39 </td> <td>0.52 </td> <td>0.29 </td>
  336. </tr>
  337. <tr>
  338. <td>Other </td> <td>0.08 </td> <td>0.18 </td> <td>0.1 </td> <td>0.16 </td>
  339. </tr>
  340. </tbody>
  341. </table>
  342. </div>
  343. </div>
  344. </div>
  345. </div>
  346. </div>
  347. </div>
  348. </div>
  349. <div class="jb_cell">
  350. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  351. <div class="text_cell_render border-box-sizing rendered_html">
  352. <p>It is natural to want to compare these distributions. It makes sense to compare the columns directly, because all the entries are proportions and are therefore on the same scale.</p>
  353. <p>The method <code>barh</code> allows us to visualize the comparisons by drawing multiple bar charts on the same axes. The call is analogous to those for <code>scatter</code> and <code>plot</code>: we have to specify the common axis of categories.</p>
  354. </div>
  355. </div>
  356. </div>
  357. </div>
  358. <div class="jb_cell">
  359. <div class="cell border-box-sizing code_cell rendered">
  360. <div class="input">
  361. <div class="inner_cell">
  362. <div class="input_area">
  363. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">usa_ca</span><span class="o">.</span><span class="n">barh</span><span class="p">(</span><span class="s1">&#39;Ethnicity&#39;</span><span class="p">)</span>
  364. </pre></div>
  365. </div>
  366. </div>
  367. </div>
  368. <div class="output_wrapper">
  369. <div class="output">
  370. <div class="jb_output_wrapper }}">
  371. <div class="output_area">
  372. <div class="output_png output_subarea ">
  373. <img src="../../../images/chapters/07/3/Overlaid_Graphs_15_0.png"
  374. >
  375. </div>
  376. </div>
  377. </div>
  378. </div>
  379. </div>
  380. </div>
  381. </div>
  382. <div class="jb_cell">
  383. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  384. <div class="text_cell_render border-box-sizing rendered_html">
  385. <p>While drawing the overlaid bar charts is straightforward, there is a bit too much information on this graph for us to be able to sort out similarities and differences between populations. It seems clear that the distributions of ethnicities for everyone in the U.S. and for children in the U.S. are more similar to each other than any other pair, but it's much easier to compare the populations one pair at a time.</p>
  386. <p>Let's start by comparing the entire populations of the U.S.A. and California.</p>
  387. </div>
  388. </div>
  389. </div>
  390. </div>
  391. <div class="jb_cell">
  392. <div class="cell border-box-sizing code_cell rendered">
  393. <div class="input">
  394. <div class="inner_cell">
  395. <div class="input_area">
  396. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">usa_ca</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="s1">&#39;Ethnicity&#39;</span><span class="p">,</span> <span class="s1">&#39;USA All&#39;</span><span class="p">,</span> <span class="s1">&#39;CA All&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">barh</span><span class="p">(</span><span class="s1">&#39;Ethnicity&#39;</span><span class="p">)</span>
  397. </pre></div>
  398. </div>
  399. </div>
  400. </div>
  401. <div class="output_wrapper">
  402. <div class="output">
  403. <div class="jb_output_wrapper }}">
  404. <div class="output_area">
  405. <div class="output_png output_subarea ">
  406. <img src="../../../images/chapters/07/3/Overlaid_Graphs_17_0.png"
  407. >
  408. </div>
  409. </div>
  410. </div>
  411. </div>
  412. </div>
  413. </div>
  414. </div>
  415. <div class="jb_cell">
  416. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  417. <div class="text_cell_render border-box-sizing rendered_html">
  418. <p>The two distributions are quite different. California has higher proportions in the <code>Hispanic</code> and <code>Other</code> categories, and correspondingly lower proportions of <code>Black</code> and <code>White</code>. The differences are largely due to California's geographical location and patterns of immigration, both historically and in more recent decades. For example, the <code>Other</code> category in California includes a significant proportion of Asians and Pacific Islanders.</p>
  419. <p>As you can see from the graph, almost 40% of the Californian population in 2014 was <code>Hispanic</code>. A comparison with the population of children in the state indicates that the <code>Hispanic</code> proportion is likely to be greater in future years. Among Californian children, 50% are in the <code>Hispanic</code> category.</p>
  420. </div>
  421. </div>
  422. </div>
  423. </div>
  424. <div class="jb_cell">
  425. <div class="cell border-box-sizing code_cell rendered">
  426. <div class="input">
  427. <div class="inner_cell">
  428. <div class="input_area">
  429. <div class=" highlight hl-ipython3"><pre><span></span><span class="n">usa_ca</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="s1">&#39;Ethnicity&#39;</span><span class="p">,</span> <span class="s1">&#39;CA All&#39;</span><span class="p">,</span> <span class="s1">&#39;CA Children&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">barh</span><span class="p">(</span><span class="s1">&#39;Ethnicity&#39;</span><span class="p">)</span>
  430. </pre></div>
  431. </div>
  432. </div>
  433. </div>
  434. <div class="output_wrapper">
  435. <div class="output">
  436. <div class="jb_output_wrapper }}">
  437. <div class="output_area">
  438. <div class="output_png output_subarea ">
  439. <img src="../../../images/chapters/07/3/Overlaid_Graphs_19_0.png"
  440. >
  441. </div>
  442. </div>
  443. </div>
  444. </div>
  445. </div>
  446. </div>
  447. </div>
  448. <div class="jb_cell">
  449. <div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
  450. <div class="text_cell_render border-box-sizing rendered_html">
  451. <p>More complex datasets naturally give rise to varied and interesting visualizations, including overlaid graphs of different kinds. To analyze such data, it helps to have some more skills in data manipulation, so that we can get the data into a form that allows us to use methods like those in this section. In the next chapter we will develop some of these skills.</p>
  452. </div>
  453. </div>
  454. </div>
  455. </div>