Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I've been playing around with the new units capability in MMA9 and I'm becoming a bit frustrated with what I perceive as an incomplete implementation of this capability and I'm wondering if there are other similar examples.

For example, Histogram[] can take a list of quantities and a TargetUnits specification and it will scale the plot appropriately:

data = Quantity[RandomVariate[NormalDistribution[0, 1], 100], "Meters"];
Histogram[data, AxesLabel -> Automatic, TargetUnits -> "Meters"]

enter image description here

Histogram[data, AxesLabel -> Automatic, TargetUnits -> "Centimeters"]

enter image description here

But the options for Histogram[] do not appear to allow units specifications, which seems dangerous to me and can have some (obvious but) strange results if care is not taken.

As an example, specifying bspec = {-3, 3, 0.2} assuming that the units are in meters results in a figure that looks something like this:

Histogram[data, {-3, 3, 0.2}, AxesLabel -> Automatic, TargetUnits -> "Meters"]

enter image description here

If we then change the TargetUnits to centimeters, here's what happens:

Histogram[data, {-3, 3, 0.2}, AxesLabel -> Automatic, TargetUnits -> "Centimeters"]

enter image description here

Needless to say, one could readily draw a completely different conclusion about the nature of the data even though the only thing that's changed is the output units.

To me this seems like an incomplete implementation and I'm wondering if anyone else has encountered a similar issue elsewhere? If so, I'm tempted to avoid the new units capability until it's more mature.

share|improve this question
5  
But isn't it what it should look like? If we set target units to centimeters then specs are in centimeters also. –  swish Dec 25 '12 at 16:02
    
I was thinking (perhaps incorrectly) that TargetUnits only applied to the output scale and that it wouldn't change the structure of a figure. I still believe that the proper way to address this question would be to add units to specs such as bspec. –  David Skulsky Dec 25 '12 at 23:01
1  
New units capability is definitely a work in progress. I've already logged 2 bug reports including one for TargetUnits because I can't even reproduce the documentation examples. For example, try ListLinePlot[RandomReal[{0, 5}, {20}], TargetUnits -> {"Seconds", "Feet"}, AxesLabel -> Automatic] Under Windows at least s is the y-axis label and there's nothing on x. –  geraldcecil Dec 27 '12 at 15:23
    
@geraldcecil: It looks like the example you listed now works in MMA 9.0.1 –  David Skulsky Jan 31 '13 at 23:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.