Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Plot Axis Unit Conversions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98880] Re: Plot Axis Unit Conversions
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Mon, 20 Apr 2009 19:13:14 -0400 (EDT)
  • References: <gsh17u$or$1@smc.vnet.net>

As a follow-up to my previous post:

The concept is easy to generalize to other unit scale conversions
using the Units package.

Needs["Units`"]

convertedScale[oldUnit_, newUnit_][min_, max_] :=
 Apply[{#1/(Convert[oldUnit, newUnit]/newUnit ), ##2} &,
  AbsoluteOptions[
    Plot[x, {x, Convert[oldUnit, newUnit]/newUnit min,
      Convert[oldUnit, newUnit]/newUnit max}, Frame -> True,
     FrameTicks -> {Automatic, None, None, None}], FrameTicks][[1, 2,
    1]], 1]

Now you can go wild:

Plot[0.25 Sin[x], {x, 0, 100}, Frame -> True,
 FrameTicks -> {convertedScale[Meter, LightYear],
   convertedScale[Meter, Centi Meter], convertedScale[Meter, Mile],
   convertedScale[Meter, Yard]},
 FrameLabel -> {"x-axis (in LightYear)", "y-axis (in cm)",
   "x-axis (in Miles)", "y-axis (in yards)"}]

Works for every unit listed in Units/guide/UnitsPackage except
temperatures. For these you have to replace Convert for
ConvertTemperature.

Cheers -- Sjoerd

On Apr 20, 7:29 am, unknowno... at gmail.com wrote:
> Hello everyone,
>
> I am working on a notebook involving a flutter analysis of a flat
> plate in a wind tunnel. All of the equations involve metric units, but
> most of the physical measurements of size I have are in inches. In
> order to maintain a consistent system of units, I would like to plot
> the axis units in metric and English units. Specifically, I have a
> plot for the critical flutter speed in units of m/s versus the chord
> length in meters, and I want to overlay an x-axis, possibly on the
> top, that will display the equivalent length in inches (i.e,
> xinches=x*10000/254) without messing up the graph. At the very least,
> I would like to display it in centimeters instead of meters for better
> clarity. I do NOT want to recalculate the function using inches - just
> display the conversion. It would be nice if I could display it in both
> inches and centimeters at the same time.
>
> This is an absolute breeze to do in another system, but I haven't been
> able to find anything specifically dealing with scaling of axes for
> Mathematica. Anyone have any ideas?
>
> Thanks very kindly!



  • Prev by Date: Re: Re: Looking for a scrolling list control, or how to create/simulate
  • Next by Date: Re: Looking for a scrolling list control, or how to create/simulate
  • Previous by thread: Re: Plot Axis Unit Conversions
  • Next by thread: Mathematica documentation - for newest and older versions