# Bug with \`linecolor = cgrad()\`?

**URL:** <https://discourse.julialang.org/t/bug-with-linecolor-cgrad/10775>\
**Category:** Visualization\
**Created:** [May 8, 2018, 10:20am UTC](https://discourse.julialang.org/t/bug-with-linecolor-cgrad/10775 "2018-05-08T10:20:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [May 8, 2018, 10:20am UTC](https://discourse.julialang.org/t/bug-with-linecolor-cgrad/10775/1 "2018-05-08T10:20:27Z")

</div>

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:

```julia
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.]

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [May 8, 2018, 10:55am UTC](https://discourse.julialang.org/t/bug-with-linecolor-cgrad/10775/2 "2018-05-08T10:55:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [May 8, 2018, 11:27am UTC](https://discourse.julialang.org/t/bug-with-linecolor-cgrad/10775/3 "2018-05-08T11:27:16Z")

</div>

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

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/3/63cd0a9ae6bcd00d96ce02a1ad95a371d0dd3d18.jpeg)

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:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/4/44eafc7034d9c520655f41b714b203f81db7dd51.jpeg)

**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…]
