# How to fix "! Dimension too large." when using pgfplotsx?

**URL:** <https://discourse.julialang.org/t/how-to-fix-dimension-too-large-when-using-pgfplotsx/126730>\
**Category:** Visualization\
**Tags:** question, plotting, plots, pgfplotsx, potential-bug\
**Created:** [March 9, 2025, 12:50pm UTC](https://discourse.julialang.org/t/how-to-fix-dimension-too-large-when-using-pgfplotsx/126730 "2025-03-09T12:50:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![homocomputeris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/homocomputeris/32/8933_2.png) [@homocomputeris](https://discourse.julialang.org/u/homocomputeris)\
**Post date:** [March 9, 2025, 12:50pm UTC](https://discourse.julialang.org/t/how-to-fix-dimension-too-large-when-using-pgfplotsx/126730/1 "2025-03-09T12:50:56Z")

</div>

When trying to plot the following `data`

```julia
VectorOfArray{Float64,2}:
2-element Vector{Vector{Float64}}:
 [0.00969160836699929, 516.6666666666663]
 [0.00974104323961814, 900.0]
VectorOfArray{Float64,2}:
2-element Vector{Vector{Float64}}:
 [0.009691608366954797, 650.0]
 [0.00974104323957102, 650.0]
VectorOfArray{Float64,2}:
2-element Vector{Vector{Float64}}:
 [0.009691608367069041, 1966.6666666666654]
 [0.00974104323959538, 1966.6666666666654]
VectorOfArray{Float64,2}:
2-element Vector{Vector{Float64}}:
 [0.009691608366954797, 650.0]
 [0.00974104323957102, 650.0]

```

with

```julia
scatter!(fig, data[2, :], data[1, :],
    markershape = markers[k], markercolor = colors[k], markersize = 6)
display(fig)
savefig(fig, "fig.pdf")

```

I get

```julia
! Dimension too large.
<recently read> \pgf@yy 
        
l.119 \end{axis}
              
ERROR: The latex command `lualatex jl_KB8t2vSnWV.tex` failed
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] savepdf(filename::String, td::PGFPlotsX.TikzDocument; latex_engine::PGFPlotsX.LaTeXEngine, buildflags::Vector{…}, run_count::Int64, tmp::String)
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/XcmEC/src/tikzdocument.jl:202
  [3] savepdf
    @ ~/.julia/packages/PGFPlotsX/XcmEC/src/tikzdocument.jl:159 [inlined]
  [4] savesvg(filename::String, td::PGFPlotsX.TikzDocument; latex_engine::PGFPlotsX.LaTeXEngine, buildflags::Vector{…}, keep_pdf::Bool)
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/XcmEC/src/tikzdocument.jl:272
  [5] savesvg
    @ ~/.julia/packages/PGFPlotsX/XcmEC/src/tikzdocument.jl:267 [inlined]
  [6] save(filename::String, td::PGFPlotsX.TikzDocument; include_preamble::Bool, latex_engine::PGFPlotsX.LaTeXEngine, buildflags::Vector{…}, dpi::Int64, showing_ide::Bool)
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/XcmEC/src/tikzdocument.jl:84
  [7] show(f::IOBuffer, ::MIME{Symbol("image/svg+xml")}, td::PGFPlotsX.TikzDocument)
    @ PGFPlotsX ~/.julia/packages/PGFPlotsX/XcmEC/src/tikzdocument.jl:294
  [8] _show(io::IOBuffer, mime::MIME{Symbol("image/svg+xml")}, plt::Plots.Plot{Plots.PGFPlotsXBackend})
    @ Plots ~/.julia/packages/Plots/Ec1L1/src/backends/pgfplotsx.jl:1371
  [9] #invokelatest#2
    @ ./essentials.jl:1055 [inlined]
 [10] invokelatest
    @ ./essentials.jl:1052 [inlined]
 [11] show
    @ ~/.julia/packages/Plots/Ec1L1/src/output.jl:232 [inlined]
 [12] __binrepr(m::MIME{Symbol("image/svg+xml")}, x::Plots.Plot{Plots.PGFPlotsXBackend}, context::Nothing)
    @ Base.Multimedia ./multimedia.jl:171
 [13] _textrepr
    @ ./multimedia.jl:163 [inlined]
 [14] stringmime(m::MIME{Symbol("image/svg+xml")}, x::Plots.Plot{Plots.PGFPlotsXBackend})
    @ Base64 ~/.julia/juliaup/julia-1.11.3+0.x64.apple.darwin14/share/julia/stdlib/v1.11/Base64/src/Base64.jl:44
 [15] display(d::VSCodeServer.InlineDisplay, m::MIME{Symbol("image/svg+xml")}, x::Any)
    @ VSCodeServer ~/.cursor/extensions/julialang.language-julia-1.127.2/scripts/packages/VSCodeServer/src/display.jl:68
 [16] display(d::VSCodeServer.InlineDisplay, mime::String, x::Any)
    @ Base.Multimedia ./multimedia.jl:228
 [17] display(d::VSCodeServer.InlineDisplay, x::Any)
    @ VSCodeServer ~/.cursor/extensions/julialang.language-julia-1.127.2/scripts/packages/VSCodeServer/src/display.jl:207
 [18] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:340
 [19] top-level scope
    @ ~/example.jl:159
Some type information was truncated. Use `show(err)` to see complete types.

```

What exactly does it mean, and how can I fix this error?

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [March 9, 2025, 1:08pm UTC](https://discourse.julialang.org/t/how-to-fix-dimension-too-large-when-using-pgfplotsx/126730/2 "2025-03-09T13:08:19Z")

</div>

To me it looks a bit similar to something like

> <https://tex.stackexchange.com/questions/13816/dimension-too-large-while-plotting-with-pgfplots>

and is a limitation of pdf-plots – or to be more precise: Imaging you spent a cm per 10 units, then your `1966` is nearly 2 meters out.  
You can restrict your y-domain first (though then you do not see all your data probably) – or scale down your data before.
