Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to show a scatter plot and bar chart next to each other in order to show the change in both factors for each county. The scatter plot shows life expectancy per county on the basis of income, while the stacked bar graph shows the change in life expectancy for females and males from 1958 to 2010. Help!

Initialization Code:

fx = {30461, 15514, 24021, 21285, 20777, 23711, 20100, 23386, 22318, 23659, 26025, 21601, 20022, 27480, 26101, 24756, 25292,  24333, 23264, 25305, 26523, 23116, 20828, 30744, 20811, 20815, 24144, 26338, 24501, 36184, 43509, 23903, 25870, 27304, 24217, 30268, 22295, 21285, 18746, 35864, 30618, 29810, 35589, 33592, 18004, 29660, 21900, 22515, 23971, 25115, 23750, 32373, 25582, 24519, 19404, 25720, 24826, 22204, 24401, 36412, 23398, 19748};
fy = {81.5, 80.1, 81.2, 81, 79.1, 81.7, 80.7, 80.1, 80, 81.3, 80.9, 79.7, 80.6, 81.8, 80.3, 81.1, 79.8, 80.6, 81, 80.5, 81.1, 81.2, 80.1, 82.4, 81.7, 81.5, 81.3, 81.6, 79.8, 80.3, 84.1, 79.6, 80.9, 81.8, 81.9, 81, 80.4, 80, 81.3, 82.4, 83.8, 79.9, 81.6, 83.4, 79.6, 82.4, 81.6, 81.8, 79.1, 80.7, 80.5, 82.3, 79.1, 82.2, 82.2, 81.2, 82, 80.4, 80.6, 84.1, 80.2, 80.5}; 
femaledata = Transpose@{fx, fy}; 
femaleplot = ListPlot[femaledata, PlotStyle -> Purple]​​;​
​mx = {39042, 27328, 27180, 30975, 30575, 34676, 29953, 34696, 31914, 31538, 36356, 29548, 28262, 43545, 36360, 31519, 29278, 32237, 35597, 32959, 31694, 32693, 33374, 33829, 35787, 32441, 33919, 36295, 31531, 54018, 54895, 35160, 32899, 37783, 36910, 42130, 33210, 32378, 25208, 54179, 34948, 37152, 51023, 46681, 26683, 46960, 21971, 32196, 34242, 32220, 35500, 50695, 32212, 35172, 28101, 38048, 37360, 33014, 36181, 51852, 35061, 31333};
my = {77.4, 77.3, 75, 76.1, 74.9, 77, 75.5, 75.6, 76.3, 76.5, 76.3, 76.9, 76.4, 77.9, 75.7, 77.3, 77, 76.1, 75.7, 75.2, 77.3, 77.2, 75.5, 77.3, 76, 77.6, 77.8, 77.6, 76.1, 79.6, 79.3, 75.5, 76.1, 76.9, 76.8, 77.6, 76.1, 75.9, 76.8, 78.7, 79, 76.5, 77.3, 76.9, 75.5, 78.7, 76.9, 77.4, 76.4, 76.8, 75.9, 78, 75, 77.6, 78.8, 77.1, 77.6, 77.2, 76.8, 79.8, 76.8, 77.1};     
maledata = Transpose@{mx, my}; 
maleplot = ListPlot[maledata, PlotStyle -> MediumBlue]​;

ScatterPlot:

Manipulate[Show[maleplot, femaleplot, Graphics[{PointSize[.02], Point[county]}], Graphics[{PointSize[.02], Point[county1]}], PlotRange -> {{10000, 60000}, {70, 85}}, AxesOrigin -> {10000, 70}, ImageSize -> 500, AxesLabel -> {"Median Income", "Life Expectancy"}], {{county,{30461, 81.5},"Female County"}, {{30461, 81.5}->"Albany", {15514, 80.1}->"Allegany", {24021, 81.2} -> "Bronx", {21285, 81} -> "Broome", {20777, 79.1} -> "Cattaraugus", {23711, 81.7} -> "Cayuga", {20100, 80.7} -> "Chautauqua", {23386, 80.1} -> "Chemung", {22318, 80} -> "Chenango", {23659, 81.3} -> "Clinton", {26025, 80.9} -> "Columbia", {21601, 79.7} -> "Cortland", {20022, 80.6} -> "Delaware", {27480, 81.8} -> "Dutchess", {26101, 80.3} -> "Erie", {24756, 81.1} -> "Essex", {25292, 79.8} -> "Franklin", {24333, 80.6} -> "Fulton", {23264, 81} -> "Genesee", {25305, 80.5} -> "Greene", {26523, 81.1} -> "Hamilton", {23116, 81.2} -> "Herkimer", {20828, 80.1} -> "Jefferson", {30744, 82.4} -> "Kings", {20811, 81.7} -> "Lewis", {20815, 81.5} -> "Livingston", {24144, 81.3} -> "Madison", {26338, 81.6} -> "Monroe", {24501, 79.8} -> "Montgomery", {36184, 80.3} -> "Nassau", {43509, 84.1} -> "NewYork", {23903, 79.6} -> "Niagara", {25870, 80.9} -> "Oneida", {27304, 81.8} -> "Onondaga", {24217, 81.9} -> "Ontario", {30268, 81} -> "OrangeCounty", {22295, 80.4} -> "Orleans", {21285, 80} -> "Oswego", {18746, 81.3} -> "Otsego", {35864, 82.4} -> "Putnam", {30618, 83.8} -> "Queens", {29810, 79.9} -> "Rensselaer", {35589, 81.6} -> "Richmond", {33592, 83.4} -> "Rockland", {18004, 79.6} -> "StLawrence", {29660, 82.4} -> "Saratoga", {21900, 81.6} -> "Schenectady", {22515, 81.8} -> "Schoharie", {23971, 79.1} -> "Schuyler", {25115, 80.7} -> "Seneca", {23750, 80.5} -> "Steuben", {32373, 82.3} -> "Suffolk", {25582, 79.1} -> "Sullivan", {24519, 82.2} -> "Tioga", {19404, 82.2} -> "Tompkins", {25720, 81.2} -> "Ulster", {24826, 82} -> "Warren", {22204, 80.4} -> "Washington", {24401, 80.6} -> Wayne, {36412, 84.1} -> "Westchester", {23398, 80.2} -> "Wyoming", {19748, 80.5} -> "Yates"}, ControlType -> PopupMenu}, {{county1, {39042, 77.4}, "Male County"}, {{39042, 77.4}->"Albany", {27328, 77.3}->"Allegany", {27180, 75} -> "Bronx", {30975, 76.1} -> "Broome", {30575, 74.9} -> "Cattaraugus", {34676, 77} -> "Cayuga", {29953, 75.5} -> "Chautauqua", {34696, 75.6} -> "Chemung", {31914, 76.3} -> "Chenango", {31538, 76.5} -> "Clinton", {36356, 76.3} -> "Columbia", {29548, 76.9} -> "Cortland", {28262, 76.4} -> "Delaware", {43545, 77.9} -> "Dutchess", {36360, 75.7} -> "Erie", {31519, 77.3} -> "Essex", {29278, 77} -> "Franklin", {32237, 76.1} -> "Fulton", {35597, 75.7} -> "Genesee", {32959, 75.2} -> "Greene", {31694, 77.3} -> "Hamilton", {32693, 77.2} -> "Herkimer", {33374, 75.5} -> "Jefferson", {33829, 77.3} -> "Kings", {35787, 76} -> "Lewis", {32441, 77.6} -> "Livingston", {33919, 77.8} -> "Madison", {36295, 77.6} -> "Monroe", {31531, 76.1} -> "Montgomery", {54018, 79.6} -> "Nassau", {54895, 79.3} -> "NewYork", {35160, 75.5} -> "Niagara", {32899, 76.1} -> "Oneida", {37783, 76.9} -> "Onondaga", {36910, 76.8} -> "Ontario", {42130, 77.6} -> "OrangeCounty", {33210, 76.1} -> "Orleans", {32378, 75.9} -> "Oswego", {25208, 76.8} -> "Otsego", {54179, 78.7} -> "Putnam", {34948, 79} -> "Queens", {37152, 76.5} -> "Rensselaer", {51023, 77.3} -> "Richmond", {46681, 76.9} -> "Rockland", {26683, 75.5} -> "StLawrence", {46960, 78.7} -> "Saratoga", {21971, 76.9} -> "Schenectady", {32196, 77.4} -> "Schoharie", {34242, 76.4} -> "Schuyler", {32220, 76.8} -> "Seneca", {35500, 75.9} -> "Steuben", {50695, 78} -> "Suffolk", {32212, 75} -> "Sullivan", {35172, 77.6} -> "Tioga", {28101, 78.8} -> "Tompkins", {38048, 77.1} -> "Ulster", {37360, 77.6} -> "Warren", {33014, 77.2} -> "Washington", {36181, 76.8} -> Wayne, {51852, 79.8} -> "Westchester", {35061, 76.8} -> "Wyoming", {31333, 77.1} -> "Yates"}, ControlType -> PopupMenu}]

Bar Chart:

Manipulate[BarChart[county, ChartLayout ->"Stacked", ChartLegends -> {"female", "male"}, ChartStyle -> "Pastel", ImageSize -> 500, AxesLabel -> {"County","Increase In Life Expectancy (Years)"}], {county, {{3.8,5.8} -> "Albany", {1.7,4.9} -> "Allegany",{6.4, 9.6} -> "Bronx",{2.5,4.2} -> "Broome",{1.7, 3.6} -> "Cattaraugus",{3.8, 5.5} -> "Cayuga",{2.9, 3.6} ->"Chautauqua",{2.2, 4.2} -> "Chemung",{1.6, 5.2} -> "Chenango",{3.3, 4.8} -> "Clinton",{2.6, 4.8} -> "Columbia", {2.1, 5.8} -> "Cortland",{2.5, 5.6} -> "Delaware",{3.6, 6.1} -> "Dutchess", {3.5, 5.3} -> "Erie",{4.4, 7} -> "Essex",{3.3, 7.2} -> "Franklin", {2.4, 4.9} -> "Fulton", {2.5, 3.9} -> "Genesee", {3.3, 4.4} -> "Greene", {4.4, 7} -> "Hamilton", {2.9, 5.1} -> "Herkimer", {3.8, 5.4} -> "Jefferson", {6.7, 9.8} -> "Kings",{3.6, 4.3} -> "Lewis",{3.1, 5} ->  "Livingston",{2.2, 6.5} -> "Madison",{3, 5.1} -> "Monroe",{1.6, 4.3} -> "Montgomery"​, {5.5, 6.7} -> "Nassau",{8.4, 13} -> "NewYork",{2.1, 4.2} -> "Niagara",{2.8, 4.5} -> "Oneida",{3.5, 5} -> "Onondoga",{3.1, 3.7} -> "Ontario",{3.7, 7.1} -> "OrangeCounty",{3.2, 5.1} -> "Orleans",{2.8, 5.3} -> "Oswego",{2.9, 4.3} -> "Otsego",{4.6, 6.7} -> "Putnam",{6, 8.5} -> "Queens",{2.3, 5.3} -> "Rensselaer",{4.7, 7.4} -> "Richmond",{5.7, 7} -> "Rockland",{2, 4.7} -> "StLawrence",{4.6, 6.2} -> "Saratoga",{3.4, 5.4} -> "Schenectady", {3.8, 5.3} -> "Schoharie",{0.4, 5.1} -> "Schuyler",{2.1, 4.4} -> "Seneca",{3.2, 4.9} -> "Steuben",{4.9, 6.1} -> "Suffolk",{2.5, 5.7} -> "Sullivan",{3.6, 5.1} -> "Tioga",{3.4, 5.5} -> "Tompkins",{3.2, 5.9} -> "Ulster",{4.7, 6.3} -> "Warren",{3, 6.7} -> "Washington",{3.1, 5} -> "Wayne",{5.5, 7.1} -> "Westchester",{2.1, 5.4} -> "Wyoming",{1.8, 4.8} -> "Yates"}, ControlType -> PopupMenu}]​​

Thanks a lot!

share|improve this question
2  
The first Manipulate produces an error for me. What do you intend to do? –  Öskå May 27 at 13:57
3  
Have you looked at Row or GraphicsRow? –  Michael E2 May 27 at 13:58
add comment

1 Answer 1

There were many typing errors in your code.

This works, but there is room for lots of improvements. The BarChart-variant you can add yourself, I think. And: What is a life-expectancy of -10.000 ? D

Manipulate[

 Column[{
   Grid[{{maleplot, femaleplot}}],
   Grid[{{
      Graphics[{PointSize[.06], Point[county]}, Axes -> True, 
       AxesLabel -> {"Median Income", "Life Expectancy"}, 
       ImageSize -> 300],
      Graphics[{PointSize[.06], Point[county1]}, Axes -> True, 
       AxesLabel -> {"Median Income", "Life Expectancy"}, 
       ImageSize -> 300]
      }}]
   }],


 Column[{
   PopupMenu[
    Dynamic@county, {{30461, 81.5} -> 
      "Female County", {30461, 81.5} -> "Albany", {15514, 80.1} -> 
      "Allegany", {24021, 81.2} -> "Bronx", {21285, 81} -> 
      "Broome", {20777, 79.1} -> "Cattaraugus", {23711, 81.7} -> 
      "Cayuga", {20100, 80.7} -> "Chautauqua", {23386, 80.1} -> 
      "Chemung", {22318, 80} -> "Chenango", {23659, 81.3} -> 
      "Clinton", {26025, 80.9} -> "Columbia", {21601, 79.7} -> 
      "Cortland", {20022, 80.6} -> "Delaware", {27480, 81.8} -> 
      "Dutchess", {26101, 80.3} -> "Erie", {24756, 81.1} -> 
      "Essex", {25292, 79.8} -> "Franklin", {24333, 80.6} -> 
      "Fulton", {23264, 81} -> "Genesee", {25305, 80.5} -> 
      "Greene", {26523, 81.1} -> "Hamilton", {23116, 81.2} -> 
      "Herkimer", {20828, 80.1} -> "Jefferson", {30744, 82.4} -> 
      "Kings", {20811, 81.7} -> "Lewis", {20815, 81.5} -> 
      "Livingston", {24144, 81.3} -> "Madison", {26338, 81.6} -> 
      "Monroe", {24501, 79.8} -> "Montgomery", {36184, 80.3} -> 
      "Nassau", {43509, 84.1} -> "NewYork", {23903, 79.6} -> 
      "Niagara", {25870, 80.9} -> "Oneida", {27304, 81.8} -> 
      "Onondaga", {24217, 81.9} -> "Ontario", {30268, 81} -> 
      "OrangeCounty", {22295, 80.4} -> "Orleans", {21285, 80} -> 
      "Oswego", {18746, 81.3} -> "Otsego", {35864, 82.4} -> 
      "Putnam", {30618, 83.8} -> "Queens", {29810, 79.9} -> 
      "Rensselaer", {35589, 81.6} -> "Richmond", {33592, 83.4} -> 
      "Rockland", {18004, 79.6} -> "StLawrence", {29660, 82.4} -> 
      "Saratoga", {21900, 81.6} -> "Schenectady", {22515, 81.8} -> 
      "Schoharie", {23971, 79.1} -> "Schuyler", {25115, 80.7} -> 
      "Seneca", {23750, 80.5} -> "Steuben", {32373, 82.3} -> 
      "Suffolk", {25582, 79.1} -> "Sullivan", {24519, 82.2} -> 
      "Tioga", {19404, 82.2} -> "Tompkins", {25720, 81.2} -> 
      "Ulster", {24826, 82} -> "Warren", {22204, 80.4} -> 
      "Washington", {24401, 80.6} -> "Wayne", {36412, 84.1} -> 
      "Westchester", {23398, 80.2} -> "Wyoming", {19748, 80.5} -> 
      "Yates"}],

   PopupMenu[
    Dynamic@county1, {{39042, 77.4} -> "Male County", {39042, 77.4} ->
       "Albany", {27328, 77.3} -> "Allegany", {27180, 75} -> 
      "Bronx", {30975, 76.1} -> "Broome", {30575, 74.9} -> 
      "Cattaraugus", {34676, 77} -> "Cayuga", {29953, 75.5} -> 
      "Chautauqua", {34696, 75.6} -> "Chemung", {31914, 76.3} -> 
      "Chenango", {31538, 76.5} -> "Clinton", {36356, 76.3} -> 
      "Columbia", {29548, 76.9} -> "Cortland", {28262, 76.4} -> 
      "Delaware", {43545, 77.9} -> "Dutchess", {36360, 75.7} -> 
      "Erie", {31519, 77.3} -> "Essex", {29278, 77} -> 
      "Franklin", {32237, 76.1} -> "Fulton", {35597, 75.7} -> 
      "Genesee", {32959, 75.2} -> "Greene", {31694, 77.3} -> 
      "Hamilton", {32693, 77.2} -> "Herkimer", {33374, 75.5} -> 
      "Jefferson", {33829, 77.3} -> "Kings", {35787, 76} -> 
      "Lewis", {32441, 77.6} -> "Livingston", {33919, 77.8} -> 
      "Madison", {36295, 77.6} -> "Monroe", {31531, 76.1} -> 
      "Montgomery", {54018, 79.6} -> "Nassau", {54895, 79.3} -> 
      "NewYork", {35160, 75.5} -> "Niagara", {32899, 76.1} -> 
      "Oneida", {37783, 76.9} -> "Onondaga", {36910, 76.8} -> 
      "Ontario", {42130, 77.6} -> "OrangeCounty", {33210, 76.1} -> 
      "Orleans", {32378, 75.9} -> "Oswego", {25208, 76.8} -> 
      "Otsego", {54179, 78.7} -> "Putnam", {34948, 79} -> 
      "Queens", {37152, 76.5} -> "Rensselaer", {51023, 77.3} -> 
      "Richmond", {46681, 76.9} -> "Rockland", {26683, 75.5} -> 
      "StLawrence", {46960, 78.7} -> "Saratoga", {21971, 76.9} -> 
      "Schenectady", {32196, 77.4} -> "Schoharie", {34242, 76.4} -> 
      "Schuyler", {32220, 76.8} -> "Seneca", {35500, 75.9} -> 
      "Steuben", {50695, 78} -> "Suffolk", {32212, 75} -> 
      "Sullivan", {35172, 77.6} -> "Tioga", {28101, 78.8} -> 
      "Tompkins", {38048, 77.1} -> "Ulster", {37360, 77.6} -> 
      "Warren", {33014, 77.2} -> "Washington", {36181, 76.8} -> 
      "Wayne", {51852, 79.8} -> "Westchester", {35061, 76.8} -> 
      "Wyoming", {31333, 77.1} -> "Yates"}]
   }]]

Mathematica graphics

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.