MathGroup Archive 1999

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

Search the Archive

Re: centering a figure

  • To: mathgroup at
  • Subject: [mg21116] Re: centering a figure
  • From: "P.J. Hinton" <paulh at>
  • Date: Fri, 17 Dec 1999 01:21:14 -0500 (EST)
  • Organization: "Wolfram Research, Inc."
  • References: <831shi$>
  • Sender: owner-wri-mathgroup at

On 12 Dec 1999, Henrik Weimer wrote:

> Using Mathematica 4, is there a way to have the Graphics displayed in a
> Cell be automatically centered on the page. I can move graphics around
> manually, but once the window is resized it won;t be centered anymore.
> Ideally, I would like someling like TextAlignment->Center that works for
> graphics.
> Any ideas? Thanks!

Use an alternative display function that writes a cell with the graphic
embedded as an inline cell.

    gr : (_Graphics | _Graphics3D | _SurfaceGraphics |
          _DensityGraphics | _ContourGraphics)
    ] :=
    {psstring, cellexpr},
    psstring = DisplayString[gr];
    cellexpr = Cell[
          {Cell[GraphicsData["PostScript", psstring]]}
        TextAlignment -> Center
    NotebookWrite[EvaluationNotebook[], cellexpr]

Once this is evaluated, you can make use of it by specifying this as the
value of the DisplayFunction option:

Plot[Sin[x], {x, 0, 2Pi}, DisplayFunction ->

P.J. Hinton
Mathematica Programming Group           paulh at
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.

  • Prev by Date: Re: Re: modified list interval calculation
  • Next by Date: Re: DiracDelta Function question
  • Previous by thread: centering a figure
  • Next by thread: coupled integral equations