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

MathGroup Archive 2013

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

Search the Archive

Re: Help with "recession bar" graph

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129752] Re: Help with "recession bar" graph
  • From: "djmpark" <djmpark at comcast.net>
  • Date: Sun, 10 Feb 2013 03:26:15 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <bvd8kg$5ca$1@smc.vnet.net> <20130208101218.5682C6934@smc.vnet.net> <CAEtRDSfq_cDYyHRchtr1Rzo93PvCAwzgRHub+R4DbhMGXa8yEA@mail.gmail.com> <19418084.65707.1360389163904.JavaMail.root@m06>

Alan,

All of which brings up a topic that confuses many users doing graphics.
There are two kinds of Options that affect the look of a plot. The first
kind affect the drawn lines, curves, surfaces and primitives. Things such as
color, shading, Mesh, PlotPoints and MaxRecursion. The second kind of Option
affects the parts of the graphic that determine the overall look independent
of the "drawn" items: such things as AspectRatio, ImageSize, Frame, Axis,
Ticks, Background, PlotRegion, etc. There is at least one option, PlotRange,
that may affect both aspects of the plot. For example, if you are combining
a ContourPlot with other elements, you may need the z PlotRange to capture
all of the contours, and the x and y ranges for the overall plot.

With the Show statement Mathematica picks up the Options from the first plot
in the Show statement and they override Options from subsequent plots. This
doesn't make a lot of sense and confuses many users. So, for example, if you
had an Epilog Option in the second plot that logically went with the second
plot, you would have to shift it to the first plot. However, you can also
put Options at the end of the Show statement and these take precedence.

So with Bob Hanlon's example:

data = {38.396359394355414`, 72.27272309523107`, 89.29538328240793`, 
   72.10010639242938`, 82.58607698201098`, 18.6576446975194`, 
   33.27870983668225`, 21.4169865528564`, 27.143317794267958`, 
   56.831020645157224`, 97.91895556654552`, 53.699909198741835`, 
   62.45884842291329`, 43.57174038250221`, 5.572069539912178`, 
   47.64601720765782`, 57.36520060575606`, 11.616476185686125`, 
   53.621120873396194`, 86.51670206163143`, 46.158001732049314`, 
   91.79901697376656`, 56.56864196802621`, 68.80447171646065`, 
   69.71270226145879`, 9.193667545986898`, 12.322285539970679`, 
   84.54474541006726`, 37.46708245474912`, 70.19095794556748`, 
   21.368052894967576`, 95.70714721558335`, 19.184901239515995`, 
   12.369028572198587`, 97.66742717262244`, 64.70934352032668`, 
   1.1657357274066413`, 57.74269869413277`, 58.529638656649155`, 
   34.40274725318369`, 52.38021809465195`, 64.42731199035626`, 
   54.74507564841295`, 32.199884547032894`, 64.85420465012712`, 
   26.538659912812435`, 43.037739816388466`, 25.366295485189113`, 
   7.604466054852992`, 92.16216075731677`};

Just add Options at the end, and here I give myself a tiny advantage by also
adding some arrows to the graphic.

Show[RegionPlot[{6 <= x <= 13, 19 <= x <= 25, 39 <= x <= 46}, {x, 0, 
   50}, {y, 0, 100}, BoundaryStyle -> None], ListLinePlot[data],
 Epilog ->
  {Arrowheads[{-0.02, 0.02}], Arrow[{{6, 95}, {13, 95}}], 
   Arrow[{{19, 95}, {25, 95}}], Arrow[{{39, 95}, {46, 95}}]},
 Frame -> False,
 AspectRatio -> 1/2,
 Axes -> True,
 ImageSize -> 400] 

With the Presentations Application this would be done as follows:

<<Presentations` 

Draw2D[
 {RegionDraw[{6 <= x <= 13, 19 <= x <= 25, 39 <= x <= 46}, {x, 0, 
    50}, {y, 0, 100}, BoundaryStyle -> None],
  ListLineDraw[data],
  Arrowheads[{-0.02, 0.02}],
  Arrow[{{6, 95}, {13, 95}}], Arrow[{{19, 95}, {25, 95}}], 
  Arrow[{{39, 95}, {46, 95}}]},
 
 AspectRatio -> 1/2,
 Axes -> True,
 ImageSize -> 400]

Constructs such as RegionDraw and ListLineDraw do not take or use any of the
overall Graphics Options and they would show as Red if used. RegionDraw does
accept BoundaryStyle because that affects the graphics primitives returned.
We just draw one thing after another, including the Arrows, without having
to use Epilog or Graphics level jumping. The overall plot Options ALWAYS go
at the end where we might expect them since they have nothing to do with the
other items.


David Park
djmpark at comcast.net 
http://home.comcast.net/~djmpark/index.html   



From: Alan G Isaac [mailto:alan.isaac at gmail.com] 

On 2/8/2013 11:12 AM, Bob Hanlon wrote:
> Show[
>   RegionPlot[
>    {6 <= x <= 13, 19 <= x <= 25, 39 <= x <= 46},
>    {x, 0, 50}, {y, 0, 100},
>    BoundaryStyle -> None],
>   ListLinePlot[data]]



This is informative, but it does not meet my needs.
You put the RegionPlot first, as needed for proper overlay, but then it
hijacks the plot properties.
I'm really looking for something equivalent to Matplotlib's axvspan, in
order to add a Graphics element to an existing plot.
For now I'm putting a rectangle in the Prolog and handling the y-coordinates
myself, but I'd welcome a better solution.

Thanks,
Alan Isaac





  • Prev by Date: Re: PDF Broken in Mathematica 9.0?
  • Next by Date: Re: Using a notebook - how to add a caption and ...
  • Previous by thread: Re: Help with "recession bar" graph
  • Next by thread: Re: Help with "recession bar" graph