Re: PairedBarChart "Education and Training pay..."
- To: mathgroup at smc.vnet.net
- Subject: [mg123950] Re: PairedBarChart "Education and Training pay..."
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Mon, 2 Jan 2012 02:44:11 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201112301204.HAA08352@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
The constants (vs, lw, and es) may need tweaking for specific monitors and operating systems, but this seems a bit simpler: labelRates = {"14.9 %", "10.3 %", "9.2 %", "7.0 %", "5.4 %", "4.0 %", "2.4 %", "1.9 %"}; rates = ToExpression@StringReplace[labelRates, " %" -> ""]; n = Length@rates; labelEarnings = {"$23,088", "$32,552", "$37,024", "$39,884", "$53,976", "$66,144", "$83,720", "$80,600"}; earnings = ToExpression@StringReplace[labelEarnings, "$" | "," -> ""]; labels = {"Some high school,\nno diploma", "High school graduate", "Some college,\nno degree", "Associate degree", "Bachelor's degree", "Master's degree", "Professional degree", "Doctoral degree"}; vs = 3.8; (* vertical scale *) lw = 17; (* label width *) es = 4000; (* earnings scale *) max = Max@earnings; Graphics@{Transpose@{Range@n, labelRates, rates, labels, earnings, labelEarnings} /. {k_, lr_, r_, l_, e_, le_} :> {Text[lr, {-r - lw/5, vs (k + .25)}], Pink, Rectangle[{-r, k vs}, {0, vs (k + .5)}], Black, Text[l, {lw/2, vs (k + .2)}], Green, Rectangle[{lw, k vs}, {lw + e/es, vs (k + .5)}], Black, Text[le, {lw*1.25 + e/es, vs (k + .25)}]}, {Black, Opacity[0.5], Line@{{0, vs}, {0, vs (n + .5)}}, Line@{{lw, vs}, {lw, vs (n + .5)}}}} Bobby On Sun, 01 Jan 2012 01:27:43 -0600, Tomas Garza <tgarza10 at msn.com> wrote: > > Hi, > Sometimes it pays to try direct lower-level programming instead of using > the ready-made graphics, especially when you come to charts. This allows > for more freedom in choosing precisely what you need. Maybe it looks > more laborious, but in the end it is rather straightforward (at least > you can understand what you're doing). I tried my hand with your > example, and produced the following, which seems to work fine: > labels = Reverse@{"Some high school,\nno diploma", "High school > graduate", "Some college,\nno degree", "Associate degree", > "Bachelor's degree", "Master's degree", "Professional degree", > "Doctoral degree"}; > rates = -Reverse at {1.9, 2.4, 4.0, 5.4, 7.0, 9.2, 10.3, 14.9}; > vmin = Table[i, {i, 0, 7}]; > hor = Partition[Riffle[rates, vmin], 2]; > earns = Table[ 3.8, {8}] + {80600, 83720, 66144, 53976, 39884, 37024, > 32552, 23088}/5000.; > horearns = Partition[Riffle[Reverse@earns, vmin], 2]; > verts = Table[i, {i, 0.5, 9.5, 1}]; > mx = Partition[Riffle[Table[0, {9}], verts], 2]; > mxearns = Partition[Riffle[Table[7.6, {9}], verts], 2]; > minmx = Partition[Riffle[hor, mx], 2]; > minmxearns = Partition[Riffle[horearns, mxearns], 2]; > Graphics[{{Pink, Rectangle[Sequence @@ #]} & /@ minmx, {Green, > Rectangle[Sequence @@ #]} & /@ minmxearns, {Opacity[0.5], > Line[{{0, -0.1}, {0, 7.6}}]}, {Opacity[0.5], Line[{{7.6, -0.1}, {7.6, > 7.6}}]}, Inset[Style[ Grid[List /@ labels, Spacings -> {0.5, > {2.0, 2.1, 2.1, 2.1, 1.9, 1.5, 1.4, 1.1}}], 8, "Label"], {3.7, > 3.5}], Table[Text[Reverse[labelsrates][[j]], hor[[j]], {1.2, -1}], {j, > 1, Length[hor]}], Table[Text[Reverse[labelsearnings][[j]], > horearns[[j]], {-1.2, -1}], {j, 1, Length[hor]}]}, PlotRange -> > {{-17.5, 23}, {-1, 9}}, ImageSize -> 500, AspectRatio -> 0.5] > Hope this helps, > -Tomas > >> Date: Fri, 30 Dec 2011 07:04:57 -0500 >> From: peacenova at yahoo.com >> Subject: PairedBarChart "Education and Training pay..." >> To: mathgroup at smc.vnet.net >> >> Dear MathGroup: >> >> I'm attempting to build a chart similar to the one appearing on the >> following web page: http://www.bls.gov/emp/ep_chart_001.htm >> >> The following is what I have done far: >> >> doctoralrate = {0, 1.9}; doctoralearning = {0, 80600}; >> profdegreerate = {0, 2.4}; profdegreeearning = {0, 83720}; >> masterdegreerate = {0, 4.0}; masterdegreeearning = {0, 66144}; >> bachelordegreerate = {0, 5.4}; bachelordegreeearning = {0, 53976}; >> associatedegreerate = {0, 7.0}; associatedegreeearning = {0,39884}; >> somecollegerate = {0, 9.2}; somecollegeearning = {0, 37024}; >> highschoolgradrate = {0, 10.3}; highschoolearning = {0, 32552}; >> somehighschoolrate = {0, 14.9}; somehighschoolearning = {0, 23088}; >> >> labels = {"Some high school, no diploma", "high school graduate", >> "Some college, no degree", "Associate degree", "Bachelor's degree", >> "Master's degree", "Professional degree", "Doctoral degree"}; >> >> labelsrates = {"1.9 %", "2.4 %", "4.0 %", "5.4 %", "7.0 %", "9.2 %", >> "10.3 %", "14.9 %"}; >> >> labelsearnings = {"$80,600", "$83,720", "$66,144", "$53,976", >> "$39,884", "$37,024", "$32,552", "$23,088"}; >> >> scalingfactorrate = 5000; >> >> PairedBarChart[ >> Reverse[scalingfactorrate {doctoralrate, profdegreerate, >> masterdegreerate, bachelordegreerate, associatedegreerate, >> somecollegerate, highschoolgradrate, somehighschoolrate}], >> Reverse[{doctoralearning, profdegreeearning, masterdegreeearning, >> bachelordegreeearning, associatedegreeearning, somecollegeearning, >> highschoolearning, somehighschoolearning}], >> ChartLayout -> "Stacked", ChartStyle -> "Rainbow", >> BarSpacing -> Large, >> ChartLabels -> {Placed[{"Unemployment Rate in 2010 (%)", >> "Median Earnings in 2010 ($)"}, Above], >> Placed[labels, "CenterAxis"], None}, AxesLabel -> "Education", >> ImageSize -> Large, PlotLabel -> "Education and Training pay...", >> ChartElementFunction -> "GlassRectangle", Axes -> {False, True}] >> >> I'm having difficulties inserting the labelsrates, outside and to the >> left of >> the Unemployment rate bars. Similarly; I want to insert the >> labelsearnings, outside and to the right of the Median Earnings bars. >> >> I'm also having difficulties separating the two vertical axes so that, >> the education level labels fit properly between the axes. >> >> Thank you for your help! >> >> Gilmar Rodr=EDguez Pierluissi -- DrMajorBob at yahoo.com