# Plotting InterpolationFunction over Quantities

What's the proper syntax to plot Interpolation functions defined over Quantities?

points = {{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}};


Change domain to Quantities:

points2 = points // Map[Replace[{x_, y_} :> {Quantity[x, "Days"], y}]];


Interpolate:

ifun2 = Interpolation[points2];


This works:

ifun[Quantity[2.5, "Days"]]

3.6875

But where's the plot:

 Plot[ifun2[x], {x, Quantity[0, "Days"], Quantity[5, "Days"]}]


(* empty *)

Yet this works:

 Plot[2 x, {x, Quantity[0, "Days"], Quantity[5, "Days"]}]


Oddly given this non-interpolated function over Quantities:

f[x_] := 2*Quantity[x, "Days"]


This works too, ie, argument x is already a Quantity:

 Plot[f[x], {x, Quantity[0, "Days"], Quantity[5, "Days"]}]

• I would use ListPlot@Table[ifun2[x], {x, Quantity[0, "Days"], Quantity[5, "Days"]}] – eldo Aug 9 '17 at 22:58
• Here's a start for an answer: ifun[QuantityMagnitude@x], since you're not interpolating over Quantity object but numbers. Alternatively, you can interpolate over Quantity[.., "Days"] (change points), but there is either a bug or poor design choice in the way Plot deals/strips Quantity from the input. You can do Plot[ifun3[Quantity[x, "Days"]], {x, 0, 5}]. Neither quite gets what I think you're after, which seems unreachable to me right now. – Michael E2 Aug 9 '17 at 23:15
• @MichaelE2, by your suggestion, there is no point in using Quantities, which is the motivation of the question. – alancalvitti Aug 10 '17 at 3:05
• Yes, that is my tentative conclusion. Or rather, I might say that it seems to me that for your use-case, Quantity has not been robustly implemented. IMO, your expectation that it would work is reasonable, and you should consider reporting it to WRI. – Michael E2 Aug 10 '17 at 3:37
• @MichaelE2, wil do that, thanks. – alancalvitti Aug 10 '17 at 4:32