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

MathGroup Archive 2011

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

Search the Archive

DiscretePlot and difference tables; trying to offset bars

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121312] DiscretePlot and difference tables; trying to offset bars
  • From: "Christopher O. Young" <cy56 at comcast.net>
  • Date: Fri, 9 Sep 2011 05:50:29 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

I've finally got bars charted to show the differences, but I'd like to
offset them from the original function values. Also, I'm getting a
divide-by-zero error somehow. I think it came in with the second
DiscretePlot.


DynamicModule[
 {
  f = x,
  a = 0,
  b = 6
  },
 
 Grid[
  {
   {InputField[Dynamic[f]]},
   {InputField[Dynamic[a], Number]},
   {InputField[Dynamic[b], Number]},
   
   {Grid[{
      {  (* 
       A row with the graph on the left and the difference table on \
right *)
       Dynamic[
        Show[{
          DiscretePlot[
           f, {x, a, b, 1},
           ExtentSize -> Full,
           ColorFunction -> "Rainbow"
           ],
          
          DiscretePlot[
           Differences[f /. x -> Range[a, b], 1][[i]], {i, 1, b - a},
           ExtentSize -> Full,
           ColorFunction -> "Rainbow"
           ],
          
          Plot[
           f, {x, a, b},
           PlotRange -> {{a, b}, {(f /. x -> a), (f /. x -> b)}},
           Mesh -> b - a - 1,
           
           GridLines -> {Range[a, b],
             Range[f /. x -> a, f /. x -> b,
              Sign[(f /. x -> b) - (f /. x -> a)]]},
           GridLinesStyle -> Directive[Gray, Dashed],
           ImageSize -> Medium
           ]
          },
         Axes -> True,
         Frame -> True,
         FrameTicks -> {True, True}
         ] (* Show *)
        ],   (* Column *)
       
       Dynamic[
        Row[   (* The difference table *)
         Table[
          Column[
           Differences[f /. x -> Range[a, b], k],
           ItemSize -> {3, 3}
           ],
          {k, 0, Exponent[f , x] + 1}
          ],
         Frame -> True,
         Alignment -> Top
         ]
        ]
       }
      },
     Frame -> True,
     Alignment -> {Left, Top}
     ] (* Grid for graph and difference table *)
    }
   },
  Frame -> All
  ] (* Grid for whole display *)
 ]





  • Prev by Date: Re: How to generate report with Mathematica script from command line
  • Next by Date: DiscretePlot filling is darker above axis than below
  • Previous by thread: Re: How to generate report with Mathematica script from command line
  • Next by thread: DiscretePlot filling is darker above axis than below