# Question about PGFPlotsX.jl

**URL:** <https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815>\
**Category:** General Usage\
**Tags:** pgfplotsx\
**Created:** [May 27, 2022, 8:39pm UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815 "2022-05-27T20:39:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [May 27, 2022, 8:39pm UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/1 "2022-05-27T20:39:17Z")

</div>

What’s wrong with this, I have installed LaTeX in my Mac M1.

```julia
julia> using PGFPlotsX

julia> pgfplotsx()
Plots.PGFPlotsXBackend()

julia> 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)
ERROR: No LaTeX installation found, figures will not be generated. Make sure either pdflatex, xelatex or lualatex are installed and that the PATH variable is correctly set.
Stacktrace:
  [1] latexengine()
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/pUwhF/src/build.jl:19
  [2] _show(io::Base64.Base64EncodePipe, mime::MIME{Symbol("image/png")}, plt::Plots.Plot{Plots.PGFPlotsXBackend})
    @ Plots ~/.julia/packages/Plots/Xv2qA/src/backends/pgfplotsx.jl:1500
  [3] show(io::Base64.Base64EncodePipe, m::MIME{Symbol("image/png")}, plt::Plots.Plot{Plots.PGFPlotsXBackend})
    @ Plots ~/.julia/packages/Plots/Xv2qA/src/output.jl:214
  [4] base64encode(::Function, ::MIME{Symbol("image/png")}, ::Vararg{Any}; context::Nothing)
    @ Base64 /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Base64/src/encode.jl:209
  [5] _binstringmime
    @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Base64/src/Base64.jl:46 [inlined]
  [6] stringmime(m::MIME{Symbol("image/png")}, x::Plots.Plot{Plots.PGFPlotsXBackend}; context::Nothing)
    @ Base64 /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Base64/src/Base64.jl:43
  [7] stringmime
    @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Base64/src/Base64.jl:43 [inlined]
  [8] display(d::VSCodeServer.InlineDisplay, m::MIME{Symbol("image/png")}, x::Plots.Plot{Plots.PGFPlotsXBackend})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/display.jl:57
  [9] display(d::VSCodeServer.InlineDisplay, mime::String, x::Any)
    @ Base.Multimedia ./multimedia.jl:216
 [10] display(d::VSCodeServer.InlineDisplay, x::Plots.Plot{Plots.PGFPlotsXBackend})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/display.jl:165
 [11] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
 [12] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [13] invokelatest
    @ ./essentials.jl:714 [inlined]
 [14] (::VSCodeServer.var"#65#69"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/eval.jl:176
 [15] withpath(f::VSCodeServer.var"#65#69"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/repl.jl:184
 [16] (::VSCodeServer.var"#64#68"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/eval.jl:153
 [17] hideprompt(f::VSCodeServer.var"#64#68"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/repl.jl:36
 [18] (::VSCodeServer.var"#63#67"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/eval.jl:124
 [19] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:511
 [20] with_logger
    @ ./logging.jl:623 [inlined]
 [21] (::VSCodeServer.var"#62#66"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/eval.jl:201
 [22] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [23] invokelatest(::Any)
    @ Base ./essentials.jl:714
 [24] macro expansion
    @ ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
 [25] (::VSCodeServer.var"#60#61")()
    @ VSCodeServer ./task.jl:429

```

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [May 27, 2022, 8:40pm UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/2 "2022-05-27T20:40:25Z")

</div>

Hi,

I’m trying to plot using Plots.jl with PGFPlotsX.jl as a backend in Visual Studio.  
I have this error message:  
No LaTeX installation found, figures will not be generated. Make sure either pdflatex or lualatex are installed and that the PATH variable is correctly set.

How do I set the PATH?

I do have latex installed. Furthermore, I can plot using PGFPlotsX using Juno (Atom) and using Jupyter Notebooks. It is only in Visual Studio when the plot fails.

Thank you.

---

<div class="post-metadata">

**Author:** ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Post date:** [May 27, 2022, 10:03pm UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/3 "2022-05-27T22:03:53Z")

</div>

If you are using PGFPlotsX.jl directly, you do not need to use the pgfplotsx() backend. This backend is supposed to work with Plots.jl. It is not required by PGFPlotsX.

If you want to plot a surface using PGPlotsX, you should try something like this:

```julia
using PGFPlotsX
using LaTeXStrings

w = range(0; stop = 2π, length = 40)
v = range(0; stop = 2π, length = 40)
f(w,v)= sin(w)*sin(v)

fig = @pgf Axis(
    {
        #view = (0, 90), #to rotate the figure set "view" to true
        colorbar,
        "colormap/viridis",
        #"colormap/jet",
        height = "10cm",
        width = "16cm",
        grid = "major",
        xlabel = L"w",
        ylabel = L"v",
        title = "A nice plot",
    },
    
    Plot3(
        {
            surf,
            #shader = "flat",
        },
        Coordinates(w, v, @. (f(w, v')))
    )
)

```

The output in VSCode is the following (it works in Atom and Jupyter as well):

 ![aa](https://global.discourse-cdn.com/julialang/original/3X/8/c/8c693574e2158b21cd0cc4380e074047934aad27.png)

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [May 29, 2022, 9:05am UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/4 "2022-05-29T09:05:20Z")

</div>

> [@VivMendes](#):
>
> ```julia
> using PGFPlotsX
> using LaTeXStrings
> 
> w = range(0; stop = 2π, length = 40)
> v = range(0; stop = 2π, length = 40)
> f(w,v)= sin(w)*sin(v)
> 
> fig = @pgf Axis(
> {
> #view = (0, 90), #to rotate the figure set "view" to true
> colorbar,
> "colormap/viridis",
> #"colormap/jet",
> height = "10cm",
> width = "16cm",
> grid = "major",
> xlabel = L"w",
> ylabel = L"v",
> title = "A nice plot",
> },
>     
> Plot3(
> {
> surf,
> #shader = "flat",
> },
> Coordinates(w, v, @. (f(w, v')))
> )
> )
> 
> ```

```julia
julia> using PGFPlotsX
       using LaTeXStrings
       
       w = range(0; stop = 2π, length = 40)
       v = range(0; stop = 2π, length = 40)
       f(w,v)= sin(w)*sin(v)
       
       fig = @pgf Axis(
           {
               #view = (0, 90), #to rotate the figure set "view" to true
               colorbar,
               "colormap/viridis",
               #"colormap/jet",
               height = "10cm",
               width = "16cm",
               grid = "major",
               xlabel = L"w",
               ylabel = L"v",
               title = "A nice plot",
           },
       
           Plot3(
               {
                   surf,
                   #shader = "flat",
               },
               Coordinates(w, v, @. (f(w, v')))
           )
       )
ERROR: PGFPlotsX.MissingExternalProgramError("No LaTeX installation found, figures will not be generated. Make sure either pdflatex, xelatex or lualatex are installed and that the PATH variable is correctly set.")
Stacktrace:
  [1] latexengine()
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/pUwhF/src/build.jl:19
  [2] save(filename::String, td::TikzDocument)
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/pUwhF/src/tikzdocument.jl:73
  [3] #save#69
    @ ~/.julia/packages/PGFPlotsX/pUwhF/src/tikzpicture.jl:34 [inlined]
  [4] save
    @ ~/.julia/packages/PGFPlotsX/pUwhF/src/tikzpicture.jl:34 [inlined]
  [5] save(filename::String, axislike::Axis; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/pUwhF/src/axislike.jl:45
  [6] save
    @ ~/.julia/packages/PGFPlotsX/pUwhF/src/axislike.jl:45 [inlined]
  [7] display(d::PGFPlotsX.PGFPlotsXDisplay, p::Axis)
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/pUwhF/src/tikzdocument.jl:356
  [8] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
  [9] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [10] invokelatest
    @ ./essentials.jl:714 [inlined]
 [11] (::VSCodeServer.var"#65#69"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/eval.jl:176
 [12] withpath(f::VSCodeServer.var"#65#69"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/repl.jl:184
 [13] (::VSCodeServer.var"#64#68"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/eval.jl:153
 [14] hideprompt(f::VSCodeServer.var"#64#68"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/repl.jl:36
 [15] (::VSCodeServer.var"#63#67"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/eval.jl:124
 [16] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:511
 [17] with_logger
    @ ./logging.jl:623 [inlined]
 [18] (::VSCodeServer.var"#62#66"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/eval.jl:201
 [19] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [20] invokelatest(::Any)
    @ Base ./essentials.jl:714
 [21] macro expansion
    @ ~/.vscode/extensions/julialang.language-julia-1.6.17/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
 [22] (::VSCodeServer.var"#60#61")()
    @ VSCodeServer ./task.jl:429

```

It gets the same error.

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [May 29, 2022, 9:08am UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/5 "2022-05-29T09:08:06Z")

</div>

I run the codes in vscode. I have installed LaTeX.

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [May 29, 2022, 9:20am UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/6 "2022-05-29T09:20:27Z")

</div>

should I install some LaTex extensions in vscode?

---

<div class="post-metadata">

**Author:** ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Post date:** [May 29, 2022, 9:56am UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/7 "2022-05-29T09:56:02Z")

</div>

In your case, does that piece of code work in Atom?

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [May 29, 2022, 3:59pm UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/8 "2022-05-29T15:59:15Z")

</div>

Yes, it works well in Atom.

---

<div class="post-metadata">

**Author:** ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Post date:** [May 29, 2022, 6:46pm UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/9 "2022-05-29T18:46:15Z")

</div>

The problem is not related to PGFPlotsX because it renders the plot in Atom. In my case, I have a local LaTeX installation (Tex live) in a Linux Ubuntu system, and the code works there. It also works on a Windows 10 machine with MiKTeX locally installed. In both, the PGFPlotsX’s version is 1.5.0.

Maybe, raise an issue next to the Julia language extension for VSCode.

---

<div class="post-metadata">

**Author:** ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Post date:** [May 29, 2022, 6:55pm UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/10 "2022-05-29T18:55:10Z")

</div>

```julia
ERROR: No LaTeX installation found, figures will not be generated. Make sure either pdflatex, xelatex or lualatex are installed and that the PATH variable is correctly set.

```

I think it is the problem of PATH, Maybe I should set the environment path

---

<div class="post-metadata">

**Author:** ![jecs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jecs/32/1781_2.png) [@jecs](https://discourse.julialang.org/u/jecs)\
**Post date:** [July 27, 2026, 2:55pm UTC](https://discourse.julialang.org/t/question-about-pgfplotsx-jl/81815/11 "2026-07-27T14:55:49Z")

</div>

I found this thread while googling the same issue. The issue is that when you launch VSCode from a launcher or shortcut, and not the terminal, it does not inherit the `PATH` variable. Opening VSCode from the terminal with `code <directory>` fixes this problem.
