MathGroup Archive 2008

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

Search the Archive

Re: BarChart

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94914] Re: BarChart
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Tue, 30 Dec 2008 05:54:27 -0500 (EST)
  • References: <gjacr1$ov2$1@smc.vnet.net>

On Dec 29, 3:38 am, P_ter <petervansumme... at gmail.com> wrote:
> Hello,
> I want to make a kind of Gantt chart.
> start={0, 135, 180, 195, 225, 270, 285, 315, 360, 375, 405, 450, 465};
> duration={495, 45, 15, 90, 45, 15, 90, 45, 15, 90, 45, 15, 150};
> end={495, 180, 195, 285, 270, 285, 375, 360, 375, 465, 450, 465, 615};
> names= {"Cooking", "Spinning 1", "Mixing 1", "Packing 1", "Spinning 2",
> "Mixing 2", "Packing 2", "Spinning 3","Mixing 3", "Packing 3",
> "Spinning 4", "Mixing 4", "Packing 4"}
> So, Cooking starts at 0, has a duration of 495 and ends at 495.
> Spinning 1 starts at 135, has a duration of 45 and ends at 180 etc.
> I would like to have all in one BarChart. I can do it, but it is very
> awkward and I also have problems e.g. Cooking does not show up in:
> b2 = BarChart[{495}, ChartLayout -> "Stepped",
>   ChartElementFunction -> "GlassRectangle", ChartStyle -> "Pastel",
>   BarOrigin -> Left, ChartLabels -> "Cooking"]
> Thanks in advance.
> with friendly greetings,
> P_ter

This does it the long way. Adjust color etc to taste.

box[xmin_,xmax_,ymin_,name_] := {GrayLevel[.85],
Rectangle[{xmin,ymin},{xmax,ymin+.8}], GrayLevel[0], Line[{{xmin,ymin},
{xmax,ymin},{xmax,ymin+.8},{xmin,ymin+.8},
      {xmin,ymin}}], Text[name,{.5(xmin+xmax),ymin+.4}]}

Show[Graphics[box @@@ Transpose@{start,end,-Range@Length@end,names}],
Frame->True, FrameTicks->{Range[0,615,30],{},Range[0,615,30],{}},
ImageSize->{600,370}]


  • Prev by Date: Re: Usages Messages
  • Next by Date: Re: Problems with Dynamic inside Panel in V7
  • Previous by thread: Re: BarChart
  • Next by thread: Re: How to remove white borders on Graphics[]?