Trouble customizing 2D plots in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg42121] Trouble customizing 2D plots in Mathematica
- From: Kevin Gross <kc144 at woh.rr.com>
- Date: Thu, 19 Jun 2003 04:00:23 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi all,
While I'm a devout Mathematica user, I do like the way some other
plotting packages handle 2D plots with large y values. Specifically,
some packages will factor out a common value, e.g., 10^3, from the
y-axis labels and displays that common value above the y-axis. Below
is my attempt at mimicking this behavior in Mathematica:
(*Standard Mathematica plot with specific PlotRange*)
p1 = Plot[x^2, {x, 0, 100}, Frame -> True, PlotRange -> {0, 6000}];
(*Attempt at producing a nicer-looking plot*)
p2 = Show[p1, FrameTicks -> {Automatic, {{0, 0}, {2000, 2}, {4000, 4},
{6000, 6}, {8000, 8}, {10000, 10}}, Automatic, Automatic},
DisplayFunction -> Identity];
p3 = Graphics[Text["*\!\(10\^3\)", Scaled[{-0.05, 1.04}], {-1.5, 0}]];
Show[p2, p3, PlotRange -> All, DisplayFunction -> $DisplayFunction];
There are a couple of problems with my approach:
1.) The text box only becomes visible when I use PlotRange->All.
However, in some plots, I wish to specify a PlotRange different from
All and still have the text box visible. For example:
(*Must use PlotRange -> All*)
Show[p2, p3, DisplayFunction -> $DisplayFunction];
2.) The coordinates and offsets I've chosen, namely Scaled[{-0.05,
1.04}], {-1.5, 0}, need to be changed if the image size is changed.
I'd like to be able to resize the graphic without messing up the
alignment of the text box relative to the y-axis. These coordinates
and offsets are also dependent on the default text size, but this
probably isn't too much of a problem. For example:
(*Sensetive to resizing*)
Show[p2, p3, ImageSize -> 8*72, PlotRange -> All, DisplayFunction ->
$DisplayFunction];
Can anyone offer a suggestion on how to accomplish my objective while
avoiding these shortcomings? Or has someone already invented this
wheel?
Many thanks,
Kevin
--
Kevin Gross
Doctoral Student
Air Force Institute of Technology
Wright Patterson AFB, OH