« View all new features in
Mathematica
9
◄
previous
|
next
►
New in
Mathematica
9
›
Units
Visualization with Units
Visualization functions like
BarChart
and
ListPlot
automatically standardize units, making it easy to compare data with different units.
In[1]:=
X
dataset1 = {Quantity[0.63`, ("Grams")/("Centimeters")^3], Quantity[0.65`, ("Grams")/("Centimeters")^3], Quantity[0.4`, ("Grams")/("Centimeters")^3], Quantity[0.56`, ("Grams")/("Centimeters")^3], Quantity[0.6`, ("Grams")/("Centimeters")^3], Quantity[0.56`, ("Grams")/("Centimeters")^3], Quantity[0.16`, ("Grams")/("Centimeters")^3], Quantity[0.6`, ("Grams")/("Centimeters")^3], Quantity[0.47`, ("Grams")/("Centimeters")^3], Quantity[0.71`, ("Grams")/("Centimeters")^3], Quantity[0.88`, ("Grams")/("Centimeters")^3], Quantity[0.87`, ("Grams")/("Centimeters")^3], Quantity[0.5`, ("Grams")/("Centimeters")^3]}; dataset2 = {Quantity[45, ("Pounds")/("Feet")^3], Quantity[33, ("Pounds")/("Feet")^3], Quantity[32, ("Pounds")/("Feet")^3], Quantity[41, ("Pounds")/("Feet")^3], Quantity[41, ("Pounds")/("Feet")^3], Quantity[37, ("Pounds")/("Feet")^3], Quantity[11, ("Pounds")/("Feet")^3], Quantity[44, ("Pounds")/("Feet")^3], Quantity[27, ("Pounds")/("Feet")^3], Quantity[46, ("Pounds")/("Feet")^3], Quantity[61, ("Pounds")/("Feet")^3], Quantity[68, ("Pounds")/("Feet")^3], Quantity[28, ("Pounds")/("Feet")^3]};
In[2]:=
X
Grid[{{ BarChart[{Quantity /@ #}, TargetUnits -> {"Centimeters"}, BarOrigin -> Left, ChartLegends -> SwatchLegend[#, LegendLayout -> "ReversedColumn"], AxesLabel -> Automatic, ImageSize -> 260] &@{"foot", "meter", "inch", "yard", "span"}, BarChart[{dataset1, dataset2}, AxesLabel -> Automatic, ChartLayout -> "Percentile", LabelingFunction -> (N[#1] &), ImageSize -> 300] }, { ListLinePlot[{dataset1, dataset2}, AxesLabel -> Automatic, Filling -> Axis, PlotLabel -> "Hardwood Density", ImageSize -> 300], ListLinePlot[Sort@Transpose[{dataset1, dataset2}], AxesLabel -> Automatic, PlotLabel -> Row[{"Correlation coefficient: ", Correlation[dataset1, dataset2]}], ImageSize -> 300] }}, Alignment -> {Left, Bottom}]
Out[2]=