Bug with `linecolor = cgrad()`?

I’m doing some parametric 3D plots, and want the line color to change with a parameter (e.g., time). So… suppose we have 3 states in an ODE, with solution vectors u1, u2, u3 that depend on a parameter (time) vector t. Suppose I do:

plot(u1,u2,u3,linecolor=cgrad([:blue,:red]),line_z=t)

This will normally produce a beautiful 3D line plot where the color changes from blue to red during the evolution of t.

In my case, it produced a greyish, boring color that was constant with t.

After some debugging, I found that the reason was that the datatype of the elements in u1, etc. was Any. When I mapped the datatype to Float64, everything worked as it should.

Question: is this a bug, or an intended behavior? All other plotting commands I have tested, work fine even with datatype Any.

[The results were not produced with DifferentialEquations, which – of course – produce results of numeric type.]

I don’t think that’s intended but not how it could happen either. Are you sure it’s not the type of t that’s important?

Ah! You are --sort of – right: it has to do with the type of tsort of. Consider this:

Here, t is a vector of type Any. Still, the legend/color bar is presented correctly…

What if I map t to Float64? Then I get the intended plot:

Question:

  1. Is this a bug, or an intended behavior?
  2. The t variable may be of float type or of integer type, depending on cases. Is there a more generic map than Float64 that can be used to capture this?

[In case anyone wonders… “usn” is not US Navy :-), but I have used colors from my employer’s graphic profile… ]