# PGFPlotsX invalid pgf key error

**URL:** <https://discourse.julialang.org/t/pgfplotsx-invalid-pgf-key-error/98839>\
**Category:** General Usage\
**Tags:** question, plotting, pgfplotsx\
**Created:** [May 14, 2023, 3:08pm UTC](https://discourse.julialang.org/t/pgfplotsx-invalid-pgf-key-error/98839 "2023-05-14T15:08:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![keynescoefen](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@keynescoefen](https://discourse.julialang.org/u/keynescoefen)\
**Post date:** [May 14, 2023, 3:08pm UTC](https://discourse.julialang.org/t/pgfplotsx-invalid-pgf-key-error/98839/1 "2023-05-14T15:08:19Z")

</div>

Hello!

When running Version 1.9.0 (2023-05-07) with the latest PGFPlotsX the following snippet gives me this error message.

When using the generic plotting functions like so, I get the error message further below.

```julia
using Plots
pgfplotsx()
plot(rand(20))

```

I am on Mac OS X 13.2.1 (Intel) and I can confirm that the following works as desired:

```julia
using PGFPlotsX

@pgf Axis(
           {
               xlabel = "Cost",
               ylabel = "Error",
           },
           Plot(
               {
                   color = "red",
                   mark = "x"
               },
               Coordinates(
                   [
                       (2, -2.8559703),
                       (3, -3.5301677),
                       (4, -4.3050655),
                       (5, -5.1413136),
                       (6, -6.0322865),
                       (7, -6.9675052),
                       (8, -7.9377747),
                   ]
               ),
           ),
       )

```

The error message is pasted below. Can someone help me debug this? I ran a pgfplot example successfully and installed the required software as per the [instructions](https://kristofferc.github.io/PGFPlotsX.jl/stable/)  
Thank you!

```julia
Error showing value of type Plots.Plot{Plots.PGFPlotsXBackend}:

**ERROR:** Invalid pgf key PGFPlotsX.Options(OrderedCollections.OrderedDict{String, Any}("color" => RGBA{Float64}(0.0,0.0,0.0,1.0), "draw opacity" => 1.0, "line width" => 1, "solid" => nothing), false)

Stacktrace:

[1] **error(**s::String**)**

@ Base ./error.jl:35

[2] **normalize_key(**x::PGFPlotsX.Options**)**

@ PGFPlotsX ~/.julia/packages/PGFPlotsX/wtVR1/src/options.jl:10

[3] **PGFPlotsX.Options(**::Pair{PGFPlotsX.Options, Nothing}, ::Vararg{Union{PGFPlotsX.MergeEntry, Pair}}; print_empty::Bool**)**

@ PGFPlotsX ~/.julia/packages/PGFPlotsX/wtVR1/src/options.jl:46

[4] **PGFPlotsX.Options(**::Pair{PGFPlotsX.Options, Nothing}, ::Vararg{Union{PGFPlotsX.MergeEntry, Pair}}**)**

@ PGFPlotsX ~/.julia/packages/PGFPlotsX/wtVR1/src/options.jl:41

[5] **pgfx_get_legend_style(**sp::Plots.Subplot{Plots.PGFPlotsXBackend}**)**

@ Plots ~/.julia/packages/Plots/esM5q/src/backends/pgfplotsx.jl:769

[6] **(::Plots.PGFPlotsXPlot)(**plt::Plots.Plot{Plots.PGFPlotsXBackend}**)**

@ Plots ~/.julia/packages/Plots/esM5q/src/backends/pgfplotsx.jl:141

[7] **_update_plot_object(**plt::Plots.Plot{Plots.PGFPlotsXBackend}**)**

@ Plots ~/.julia/packages/Plots/esM5q/src/backends/pgfplotsx.jl:1359

[8] **prepare_output(**plt::Plots.Plot{Plots.PGFPlotsXBackend}**)**

@ Plots ~/.julia/packages/Plots/esM5q/src/plot.jl:257

[9] **display(**#unused#::Plots.PlotsDisplay, plt::Plots.Plot{Plots.PGFPlotsXBackend}**)**

@ Plots ~/.julia/packages/Plots/esM5q/src/output.jl:168

[10] **display(**x::Any**)**

@ Base.Multimedia ./multimedia.jl:340

[11] **#invokelatest#2**

@ ./essentials.jl:816 [inlined]

[12] **invokelatest**

@ ./essentials.jl:813 [inlined]

[13] **print_response(**errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay}**)**

@ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:305

[14] **(::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(**io::Any**)**

@ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:287

[15] **with_repl_linfo(**f::Any, repl::REPL.LineEditREPL**)**

@ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:557

[16] **print_response(**repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool**)**

@ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:285

[17] **(::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(**s::REPL.LineEdit.MIState, buf::Any, ok::Bool**)**

@ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:899

[18] **#invokelatest#2**

@ ./essentials.jl:816 [inlined]

[19] **invokelatest**

@ ./essentials.jl:813 [inlined]

[20] **run_interface(**terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState**)**

@ REPL.LineEdit /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2647

[21] **run_frontend(**repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef**)**

@ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300

[22] **(::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()**

@ REPL ./task.jl:514

```

---

<div class="post-metadata">

**Author:** ![lmg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmg/32/32312_2.png) [@lmg](https://discourse.julialang.org/u/lmg)\
**Post date:** [May 15, 2023, 11:37am UTC](https://discourse.julialang.org/t/pgfplotsx-invalid-pgf-key-error/98839/2 "2023-05-15T11:37:52Z")

</div>

Can confirm. I encountered the same error message when I was trying to create a TikZ figure using the Plots package. OP’s first MWE also raises this error on my machine.

Setup: Julia 1.9.0 (2023-05-07) with PGFPlotsX v1.6.0 and Plots v1.38.11 on Fedora (Linux x86\_64)

**Edit:** After installing the additional package PGFPlots (v3.4.2), the issue has been resolved for me. The MWE works properly now.

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [May 15, 2023, 12:15pm UTC](https://discourse.julialang.org/t/pgfplotsx-invalid-pgf-key-error/98839/3 "2023-05-15T12:15:11Z")

</div>

This is fixed on master and will be released today. See [Key normalization broke Plots backend · Issue #317 · KristofferC/PGFPlotsX.jl · GitHub](https://github.com/KristofferC/PGFPlotsX.jl/issues/317) for reference.

---

<div class="post-metadata">

**Author:** ![keynescoefen](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@keynescoefen](https://discourse.julialang.org/u/keynescoefen)\
**Post date:** [May 15, 2023, 5:20pm UTC](https://discourse.julialang.org/t/pgfplotsx-invalid-pgf-key-error/98839/4 "2023-05-15T17:20:53Z")

</div>

Thank you! I ran `Pkg.update()` and then ran my MWE again and it worked well. Beautiful plots! What a wonderful technology!
