# PGFPlotsX and color map

**URL:** https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868
**Category:** Visualization
**Tags:** plotting, pgfplotsx
**Created:** [October 27, 2018, 6:32pm UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868 "2018-10-27T18:32:18Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [October 27, 2018, 6:32pm UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868/1 "2018-10-27T18:32:18Z")

</div>

I want to use a different color map than “hot”. When I try to use the “viridis” color map, I get an error.  
It isn’t clear to me why it should be so, since the latex code matches what I can find in the PGF manual.

```julia
@pgf ax = Axis({
    view = (0, 90),
    height = "11cm",
    width = "14cm",
    xlabel = "Frequency",
    ylabel = "Angle",
    grid="major",
    colormap_name="hot",
    enlargelimits = false
}, 
Plot3({surf,shader="interp",samples=1,patch_type="rectangle"}, Table(frequencies, phis, scatp))
)

```

This works when color map is “hot”, but fails with

```julia
julia> include("acousticcolor.jl")! Missing number, treated as zero.
<to be read again>\pgfpl@cm@viridis@size
l.4562 \end{axis}
ERROR: LoadError: The latex command `lualatex julia0jx0Ch.tex` failed
...

```

The generated latex code reads:

```julia
\begin{axis}[view={0}{90}, height={11cm}, width={14cm}, xlabel={Frequency}, ylabel={Angle}, grid={major}, colormap name={viridis}, enlargelimits={false}]
    \addplot3[surf, shader={interp}, samples={1}, patch type={rectangle}]
        table[row sep={\\}]
...

```

Any hints will be appreciated.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [October 27, 2018, 7:05pm UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868/2 "2018-10-27T19:05:31Z")

</div>

You did not include an MWE, so the only thing I can confirm is that both versions below work fine for me:

```julia
using PGFPlotsX
x = 1:5
z = x .+ x'
@pgf Axis({"colormap/viridis"}, Plot3({surf}, Table(x, x, z)))
@pgf Axis({colormap_name = "viridis"}, Plot3({surf}, Table(x, x, z)))

```

producing  
 ![x](https://global.discourse-cdn.com/julialang/original/3X/f/2/f20d582e4e762faae1f3a1740facc3cf659c0663.png)

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [October 27, 2018, 7:11pm UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868/3 "2018-10-27T19:11:37Z")

</div>

Thanks for the example. It fails for me.

```julia
julia> include("try.jl")
! Package pgfplots Error: The colormap `viridis' is undefined! Maybe you misspe
lled it?.

See the pgfplots package documentation for explanation.
Type H <return> for immediate help.
 ...

l.47 \end{axis}

Error showing value of type Axis:
ERROR: The latex command `lualatex juliaef4Hf8.tex` failed

```

Perhaps I need to update the pgfplots package?

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [October 27, 2018, 7:13pm UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868/4 "2018-10-27T19:13:55Z")

</div>

> <https://tex.stackexchange.com/questions/300752/pgfplots-viridis-colormap/300756#300756>

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [October 27, 2018, 9:13pm UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868/5 "2018-10-27T21:13:48Z")

</div>

Thanks for the pointer. I’m still working on the update of PGF plots, since my Ubuntu TeX Live doesn’t want to do it. Oh well.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [October 28, 2018, 3:18am UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868/6 "2018-10-28T03:18:01Z")

</div>

I erased texlive (`sudo apt-get remove texlive`), and the newly installed texlive now lives in `/usr/local/texlive/2018`, so that I get for `which lualatex` =\> `/usr/local/texlive/2018/bin/x86_64-linux/lualatex`. So I presume that’s what is found when I do `build PGFPlotsX`. Unfortunately the plotting with the viridis color map still fails with the same error. I tried updating: `sudo /usr/local/texlive/2018/bin/x86_64-linux/tlmgr update --all` claims no update is available. So if pgfplots is up-to-date, why is the color map still not found? Any ideas?

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [October 28, 2018, 3:26am UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868/7 "2018-10-28T03:26:51Z")

</div>

> [@Tamas\_Papp](#):
>
> using PGFPlotsX x = 1:5 z = x .+ x’ @pgf Axis({“colormap/viridis”}, Plot3({surf}, Table(x, x, z)))

A restart of the Linux machine, and the viridis colormap now displays. However, this time it is the “jet” colormap that is not found!

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [October 28, 2018, 3:36am UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868/8 "2018-10-28T03:36:18Z")

</div>

This thing is VERY fiddly: to get the jet color map to work I have to do `"colormap/jet"`, `colormap_name="jet"` does not work. On the other hand `colormap_name="viridis"` works fine.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [October 28, 2018, 7:31am UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868/9 "2018-10-28T07:31:46Z")

</div>

> [@PetrKryslUCSD](#):
>
> `colormap_name="jet"` does not work

I am afraid that is a pgfplots thing we can do little about.

I am surprised that Ubuntu TeXLive does not work for you, are you on 18.04?

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [October 28, 2018, 5:08pm UTC](https://discourse.julialang.org/t/pgfplotsx-and-color-map/16868/10 "2018-10-28T17:08:08Z")

</div>

Of course, my “fiddly” comment was directed at pgfplots (no ‘X’ ;)). I will try to debug the pgfplots colormaps a bit by looking at the generated latex. When something doesn’t work for me, it is usually MODF ( my own damn fault). For what it’s worth, here is my opinion: pgfplots and PGFPlotsX are extremely impressive software, which produce astonishing graphics in camera-ready quality. Many thanks to the authors!

The texlive installation business must have to do with the fact that I am running it as a Windows Subsystem for Linux (WSL). I am currently on Ubuntu 14.04. (I know, I should upgrade, and I will at some point.)
