I have data, with units, organized as a list of rules; this is so I can slice the data in different ways based on the variables represented.
I'm trying to find the most direct way to plot this and get axis titles with both the variable from the rule and unit from the values. I don't want to manually label the plots each time, so if Plot doesn't have a built-in then how can I write a function to do the inference? I'm looking for the most DRY approach possible.
This gives me the units, but not the variable names, in the labels:
data = {
y -> {0, 33.2} (Quantity[1, ("KipsForce")/("Inches")^2]),
x -> {0, 6} 10^-4
};
ListLinePlot[Transpose@({x, y} /. data), AxesLabel -> Automatic]
On the same example, is it possible to retain units like "in/in"? I've done this by manually specifying the labels and using HoldForm
to avoid evaluating the cancellation, but I can't get that to work with automatic labels as above.