Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: PairedBarChart "Education and Training pay..."

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124412] Re: PairedBarChart "Education and Training pay..."
  • From: Tomas Garza <tgarza10 at msn.com>
  • Date: Thu, 19 Jan 2012 05:07:10 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201112301204.HAA08352@smc.vnet.net>

Hello, Gilmar:
I think your problem, as I see it, has two sources: first, using Graphics@{} makes it difficult for you to distinguish between the list of graphics primitives and the options. As it is, you have everything in the same{}. I would rather use the ordinary notation Graphics[{...},...] in order to control properly the options. Second, I think using Offset to control the position of an Inset is not a good idea. I played around with it and I think the following gives a better result:
 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;


educationandtrainingchart =     Graphics[{Transpose@{Range@n, labelRates, rates, labels, earnings,       labelEarnings} /. {k_, lr_, r_, l_, e_,       le_} :> {Style[Text[lr, {-r - lw/5, vs (k + .25)}], Bold,        Medium, FontFamily -> "Times"], EdgeForm[Thick],Black, Pink,       Rectangle[{-r, k vs}, {0, vs (k + .5)}], EdgeForm[Thick], Black,       Style[Text[l, {lw/2, vs (k + .2)}], Bold, Medium,        FontFamily -> "Times"], Green,       Rectangle[{lw, k vs}, {lw + e/es, vs (k + .5)}],       EdgeForm[Thick], Black,       Style[Text[le, {lw*1.25 + e/es, vs (k + .25)}], Bold, Medium],       FontFamily -> "Times"}, {Black, Opacity[0.5], Thick,     Line@{{0, vs}, {0, vs (n + .5)}},     Line@{{lw, vs}, {lw, vs (n + .5)}}},    Inset[Text[     Style[Framed["Education and Training pay..."], 16, Black, Bold,       Background -> Lighter[Yellow]]], Offset[{100, 360}, {0, 0}]],    Inset[Text[     Style["Unemployment Rate in 2010 (Percent)", Medium, Bold,       FontFamily -> "Times"
 ]!
], Offset[{-35, 320}, {0, 0}]],    Inset[Text[     Style["Median Earnings in 2010 (Dollars)", Medium, Bold,       FontFamily -> " Times"]], Offset[{270, 320}, {0, 0}]]},   ImageSize -> 500]
By the way, I also reduced the image size.
I hope this can be of help.
-Tomas

> Date: Wed, 18 Jan 2012 05:57:46 -0500
> From: peacenova at yahoo.com
> Subject: Re: PairedBarChart "Education and Training pay..."
> To: mathgroup at smc.vnet.net
>
> The following is in reference to:
>
> http://forums.wolfram.com/mathgroup/archive/2012/Jan/msg00040.html
>
> First of all; I want to thank Dr.MajorBob and Tomas Garza for their valuable help!
>
> I have modified Bobby's code (to get closer to my goal of producing the chart) as follows:
>
> 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;
>
> (**Please; ignore some of the underlining done automatically by my e-mail software **)
>
> educationandtrainingchart > Graphics@{Transpose@{Range@n, labelRates, rates, labels, earnings , labelEarnings}/. {k_, lr_, r_, l_, e_, le_} :>
> {Style[Text[lr, {-r - lw/5, vs (k + .25)}], Bold, Medium, FontFamily -> "Times"],
>  EdgeForm[Thick], Black, Pink, Rectangle[{-r, k vs}, {0, vs (k + .5)}],
>  EdgeForm[Thick], Black, Style[Text[l, {lw/2, vs (k + .2)}], Bold, Medium,
>  FontFamily -> "Times"], Green, Rectangle[{lw, k vs}, {lw + e/es, vs (k + .5)}], EdgeForm[Thick], Black, Style[Text[le, {lw*1.25 + e/es, vs (k + .25)}], Bold, Medium], FontFamily -> "Times"},
> {Black, Opacity[0.5], Thick, Line@{{0, vs}, {0, vs (n + .5)}}, Line@{{lw, vs},
> {lw, vs (n + .5)}}},
> Inset[Text[Style[Framed["Education and Training pay..."], 16, Black, Bold,
>  Background -> Lighter[Yellow]]], Offset[{100, 360}, {0, 0}]],
> Inset[Text[Style["Unemployment Rate in 2010 (Percent)", Medium, Bold,
>  FontFamily -> "Times"]], Offset[{-150, 320}, {0, 0}]],
> Inset[Text[Style["Median Earnings in 2010 (Dollars)", Medium, Bold,
>  FontFamily -> "Times"]], Offset[{270, 320}, {0, 0}]], ImageSize -> 1000}
>
> After evaluating the above code and the chart is rendered by Mathematica;
> the chart appears all "crumbled up" so; I used the chart's window handles
> to expand the chart within the Mathematica notebook.
>
> Unfortunately; when I attempt to export it via:
>
> Export["C:\\Temp\\educandtrainingpay.jpg", educationandtrainingchart]
>
> The chart image is still all crumbled up.  How can I fix this problem so that
> the chart's image is exported correctly?
>
> Thank you!
>
> Gilmar Rodriguez Pierluissi


  • Prev by Date: Re: without individual scaling?
  • Next by Date: Re: without individual scaling?
  • Previous by thread: Re: PairedBarChart "Education and Training pay..."
  • Next by thread: Manipulate auto re-evaluation logic puzzler