Pgfplotsx, plots: non-uniform colormaps only partially implemented

Hi,
I have an error at the level of pgfplots package when using pgfplotsx() backend to draw surfaces. Here is the working example provided by the Plots documentation

surface(range(-3,3, length=30), range(-3,3, length=30),
               (x, y)->exp(-x^2-y^2),
               label="",
               colormap_name = "viridis",
               extra_kwargs =:subplot)

returns

! Package pgfplots Error: Sorry, non-uniform colormaps are only partially imple
mented, yet: the provided points must be multiples of the mesh width h=0.11157p
t (but I found one with H/h = 0.11201pt/0.11157pt = 1+-0.004 which is no intege
r). Perhaps it helps to provide the mesh widths as argument as in {<name>}{[1cm
] <color arguments>}? The error occured near `rgb(0.50196078cm)=(0.73568300,0.2
1590600,0.33024500)'.

However, other types of 3d plot are working, like for instance (also from Plots doc)

n = 100
ts = range(0, stop = 8Ď€, length = n)
x = ts .* map(cos, ts)
y = (0.1ts) .* map(sin, ts)
z = 1:n
plot(x, y, z, zcolor = reverse(z), m = (10, 0.8, :blues, Plots.stroke(0)), leg = false, cbar = true, w = 5)
plot!(zeros(n), zeros(n), 1:n, w = 10)

Now you may need me to give you a bit of context:
I have just upgraded Julia from 1.1.1 to 1.5.2. On the previous version 1.1.1, I had a segmentation fault for any kind of plots, and in the log, there was something like

_update_subplot_colors at /home/antonin/.julia/packages/Plots/cc8wh/src/args.jl:1446
_update_subplot_args at /home/antonin/.julia/packages/Plots/cc8wh/src/args.jl:1533
unknown function (ip: 0x7f4b833a94cb)
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1842
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2197
_subplot_setup at /home/antonin/.julia/packages/Plots/cc8wh/src/pipeline.jl:299
_plot! at /home/antonin/.julia/packages/Plots/cc8wh/src/plot.jl:206

After the upgrading, everything is working just fine except the surface with pgfplotsx backend. I can draw surfaces with other backends. That may be a completely different problem, but that was the beginning of my troubles with pgfplotsx, that was working great before a global package update in Julia 1.1.1.
Thanks a lot for your help

What version of Plots.jl are you on? That example works for me on Plots v.1.6.7

1 Like

Same version as me. The problem seems related to my installation of pgfplots, maybe a missing dependency ?

You could try updating your latex-packages

1 Like

Thanks for this remark, this is clearly an option to consider. I am just afraid to do it by superstition (all my previous troubles have emerged after package update in Julia or latex), so I may postpone it after submitting the manuscript I am writing.

Assuming you are using version control (if you aren’t, you should, eg git), you can always just roll back to a previous state if you commit the relevant Manifest.toml.

1 Like

For reference: my pgfplots version is 1.17 (you can check that via texdoc pgfplots)

1 Like

Indeed, my version is 1.13. As my TeX Live manager was frozen, I am reinstalling all \LaTeX anyway :slight_smile:. Thanks @Tamas_Papp for letting me know about Manifest.toml. I did not use it.
Plotting surface should normally work after this update.

No :angry: , I still have the same error after updating pgfplots to 1.17 (in fact after having updated all latex packages).

Too bad, can you save that plot as .tex via savefig and paste the file here?

Here is the .tex generated by the surface command, but only with a four points grid.

\begin{tikzpicture}[/tikz/background rectangle/.style={fill={rgb,1:red,1.0;green,1.0;blue,1.0}, draw opacity={1.0}}, show background rectangle]
\begin{axis}[point meta max={1.522997974471263e-8}, point meta min={1.522997974471263e-8}, legend cell align={left}, title={}, title style={at={{(0.5,1)}}, anchor={south}, font={{\fontsize{14 pt}{18.2 pt}\selectfont}}, color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, rotate={0.0}}, legend style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, line width={1}, solid, fill={rgb,1:red,1.0;green,1.0;blue,1.0}, fill opacity={1.0}, text opacity={1.0}, font={{\fontsize{8 pt}{10.4 pt}\selectfont}}, at={(1.02, 1)}, anchor={north west}}, axis background/.style={fill={rgb,1:red,1.0;green,1.0;blue,1.0}, opacity={1.0}}, anchor={north west}, xshift={1.0mm}, yshift={-1.0mm}, width={145.4mm}, height={99.6mm}, scaled x ticks={false}, xlabel={}, x tick style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, opacity={1.0}}, x tick label style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, opacity={1.0}, rotate={0}}, xlabel style={at={(ticklabel cs:0.5)}, anchor=near ticklabel, font={{\fontsize{11 pt}{14.3 pt}\selectfont}}, color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, rotate={0.0}}, xmajorgrids={true}, xmin={-3.0}, xmax={3.0}, xtick={{-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0}}, xticklabels={{$-3$,$-2$,$-1$,$0$,$1$,$2$,$3$}}, xtick align={inside}, xticklabel style={font={{\fontsize{8 pt}{10.4 pt}\selectfont}}, color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, rotate={0.0}}, x grid style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={0.1}, line width={0.5}, solid}, axis x line*={left}, x axis line style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, line width={1}, solid}, scaled y ticks={false}, ylabel={}, y tick style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, opacity={1.0}}, y tick label style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, opacity={1.0}, rotate={0}}, ylabel style={at={(ticklabel cs:0.5)}, anchor=near ticklabel, font={{\fontsize{11 pt}{14.3 pt}\selectfont}}, color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, rotate={0.0}}, ymajorgrids={true}, ymin={-3.0}, ymax={3.0}, ytick={{-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0}}, yticklabels={{$-3$,$-2$,$-1$,$0$,$1$,$2$,$3$}}, ytick align={inside}, yticklabel style={font={{\fontsize{8 pt}{10.4 pt}\selectfont}}, color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, rotate={0.0}}, y grid style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={0.1}, line width={0.5}, solid}, axis y line*={left}, y axis line style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, line width={1}, solid}, scaled z ticks={false}, zlabel={}, z tick style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, opacity={1.0}}, z tick label style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, opacity={1.0}, rotate={0}}, zlabel style={, font={{\fontsize{11 pt}{14.3 pt}\selectfont}}, color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, rotate={0.0}}, zmajorgrids={true}, zmin={1.522997974471263e-8}, zmax={1.0000000152299797}, ztick={{0.2,0.4,0.6000000000000001,0.8,1.0}}, zticklabels={{$0.2$,$0.4$,$0.6$,$0.8$,$1.0$}}, ztick align={inside}, zticklabel style={font={{\fontsize{8 pt}{10.4 pt}\selectfont}}, color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, rotate={0.0}}, z grid style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={0.1}, line width={0.5}, solid}, axis z line*={left}, z axis line style={color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, line width={1}, solid}, colormap name={plots1}, colorbar, colorbar style={title={}, xticklabel style={font={{\fontsize{8 pt}{10.4 pt}\selectfont}}, color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, rotate={0.0}}, yticklabel style={font={{\fontsize{8 pt}{10.4 pt}\selectfont}}, color={rgb,1:red,0.0;green,0.0;blue,0.0}, draw opacity={1.0}, rotate={0.0}}}, view={30}{30}, colormap name={viridis}]
    \addplot3[color={rgb,1:red,0.7328;green,0.2143;blue,0.3321}, name path={26a91c05-db1a-49db-a4e4-c44d5946a574}, surf, mesh/rows={2}, mesh/cols={2}, z buffer={sort}, forget plot]
        table[row sep={\\}]
        {
            \\
            -3.0  -3.0  1.522997974471263e-8  \\
            3.0  -3.0  1.522997974471263e-8  \\
            -3.0  3.0  1.522997974471263e-8  \\
            3.0  3.0  1.522997974471263e-8  \\
        }
        ;
\end{axis}
\end{tikzpicture}
1 Like

Okay, my fault :sweat_smile:, can you use the following plot

surface(range(-3,3, length=30), range(-3,3, length=30),
               (x, y)->exp(-x^2-y^2),
               label="",
               colormap_name = "viridis",
               extra_kwargs =:subplot,
               tex_output_standalone = true
)
2 Likes

The surface is properly generated when I compile the standalone file with pdflatex. The file has too many lines even with a 2 points grid. But I guess that we both have the exact same file generated. My problem may be located at the level of lualatex compiler.

Many thanks for this alternative solution by the way. I can generate the surface by pdflatex at least.

1 Like

Sorry for not being clear, the error is still there when I compile with pdflatex but the graph appears without problem with

 pdflatex \\nonstopmode\\input plot.tex

I do not see any visual impact that may be caused by this error, when I force it to be ignored by the compiler.

Here is the output after the compilation with error ignored. Personally, I don’t see where this “non-uniform colormaps” may act.