JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.84k stars 355 forks source link

Dimension too large (PGFPlots) #685

Open lmagno opened 7 years ago

lmagno commented 7 years ago

Hi,

I stumbled upon this and can't figure out what is happening

julia> using Plots

julia> pgfplots()
Plots.PGFPlotsBackend()

julia> plot([1, 2, 3, 4], [1000.0, 1000.0, 1000.0, 999.99])  # works
julia> plot([1, 2, 3, 4], [1000.0, 1000.0, 1000.0, 999.999])
! Dimension too large.
<recently read> \pgf@yy 

l.35 \end{axis}

Error saving as SVG
Error showing value of type Plots.Plot{Plots.PGFPlotsBackend}:
ERROR: LaTeX error
 in save(::TikzPictures.PDF, ::TikzPictures.TikzPicture) at /home/magno/.julia/v0.5/TikzPictures/src/TikzPictures.jl:199
 in save(::TikzPictures.SVG, ::TikzPictures.TikzPicture) at /home/magno/.julia/v0.5/TikzPictures/src/TikzPictures.jl:247
 in _display(::Plots.Plot{Plots.PGFPlotsBackend}) at /home/magno/.julia/v0.5/Plots/src/backends/pgfplots.jl:377
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::Plots.Plot{Plots.PGFPlotsBackend}) at /home/magno/.julia/v0.5/Plots/src/output.jl:138
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::Plots.Plot{Plots.PGFPlotsBackend}) at ./REPL.jl:135
 in display(::Plots.Plot{Plots.PGFPlotsBackend}) at ./multimedia.jl:143
 in hookless(::Media.##7#8{Plots.Plot{Plots.PGFPlotsBackend}}) at /home/magno/.julia/v0.5/Media/src/compat.jl:14
 in render(::Media.NoDisplay, ::Plots.Plot{Plots.PGFPlotsBackend}) at /home/magno/.julia/v0.5/Media/src/compat.jl:27
 in display(::Media.DisplayHook, ::Plots.Plot{Plots.PGFPlotsBackend}) at /home/magno/.julia/v0.5/Media/src/compat.jl:9
 in display(::Plots.Plot{Plots.PGFPlotsBackend}) at ./multimedia.jl:143
 in print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:154
 in print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:139
 in (::Base.REPL.##22#23{Bool,Base.REPL.##33#42{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:652
 in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1579
 in run_frontend(::Base.REPL.LineEditREPL, ::Base.REPL.REPLBackendRef) at ./REPL.jl:903
 in run_repl(::Base.REPL.LineEditREPL, ::Base.##930#931) at ./REPL.jl:188
 in _start() at ./client.jl:360

It works fine using PGFPlots directly, though, and other backends.

I have

julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)

julia> Pkg.status()
 - PGFPlots                      1.4.3+             master
 - Plots                         0.10.3+            master
 - TikzPictures                  0.3.5
KristofferC commented 7 years ago

Can you save the tex file and create a minimum example for the tex file that is broken.

lmagno commented 7 years ago

This is the tex from PGFPlots (works):

\RequirePackage{luatex85}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{every axis legend/.append style={%
cells={anchor=west}}
}
\usepgfplotslibrary{polar}
\usetikzlibrary{arrows}
\tikzset{>=stealth'}

\begin{document}
\begin{tikzpicture}[]
\begin{axis}\addplot+ coordinates {
(1.0, 1000.0)
(2.0, 1000.0)
(3.0, 1000.0)
(4.0, 999.999)
};
\end{axis}

\end{tikzpicture}
\end{document}

This is cleaned up from Plots (error)

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{every axis legend/.append style={%
cells={anchor=west}}
}
\usepgfplotslibrary{polar}
\usetikzlibrary{arrows}
\tikzset{>=stealth'}

\begin{document}
\begin{tikzpicture}[]
\begin{axis}[width = {152.4mm}, ymax = {1000.0}, height = {101.6mm}, ymin = {999.999}, xmax = {4.0}, xmin = {1.0}]\addplot+ coordinates {
(1.0, 1000.0)
(2.0, 1000.0)
(3.0, 1000.0)
(4.0, 999.999)
};
\addlegendentry{y1}
\end{axis}

\end{tikzpicture}
\end{document}

I tried changing it to

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{every axis legend/.append style={%
cells={anchor=west}}
}
\usepgfplotslibrary{polar}
\usetikzlibrary{arrows}
\tikzset{>=stealth'}

\begin{document}
\begin{tikzpicture}[]
\begin{axis}[width = {152.4mm}, ymax = {1000.0}, height = {101.6mm}, ymin = {999.99}, xmax = {4.0}, xmin = {1.0}]\addplot+ coordinates {
(1.0, 1000.0)
(2.0, 1000.0)
(3.0, 1000.0)
(4.0, 999.99)
};
\addlegendentry{y1}
\end{axis}

\end{tikzpicture}
\end{document}

and now it gives "undefined control sequence" instead of "dimension too large" (maybe I'm missing something, I just compiled directly with lualatex).

EDIT: turns out putting \RequirePackage{luatex85} solves the "undefined control sequence", so now ymin = {999.99} is compilable, while ymin = {999.9999} only gives the warning

Package pgfplots Warning: Axis range for axis y is approximately empty; enlargi
ng it (it is [999.9998000000000:1000.0000000]) on input line 21.
BeastyBlacksmith commented 4 years ago

still errors on pgfplotsx-backend

putianyi889 commented 1 year ago

I'm guessing it's because of bad ylims. I have the same error in a different situation. Actively reorganising the data could be the way to solve it.

julia> plot(100*rand(100), ylims=(0,1))
! Dimension too large.
\pgfplotsaxisdeserializedatapointfrom@private@LUA ...
                                                  \pgfplotsaxisdeserializeda...
l.145 \end{axis}

Error showing value of type Plots.Plot{Plots.PGFPlotsXBackend}:
ERROR: The latex command `lualatex jl_Olg9KDoFQj.tex` failed
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:35
  [2] savepdf(filename::String, td::PGFPlotsX.TikzDocument; latex_engine::PGFPlotsX.LaTeXEngine, buildflags::Vector{String}, run_count::Int64, tmp::String)
    @ PGFPlotsX C:\Users\pty\.julia\packages\PGFPlotsX\78BAg\src\tikzdocument.jl:202
  [3] savepdf
    @ C:\Users\pty\.julia\packages\PGFPlotsX\78BAg\src\tikzdocument.jl:159 [inlined]
  [4] savesvg(filename::String, td::PGFPlotsX.TikzDocument; latex_engine::PGFPlotsX.LaTeXEngine, buildflags::Vector{String}, keep_pdf::Bool)
    @ PGFPlotsX C:\Users\pty\.julia\packages\PGFPlotsX\78BAg\src\tikzdocument.jl:272
  [5] savesvg
    @ C:\Users\pty\.julia\packages\PGFPlotsX\78BAg\src\tikzdocument.jl:267 [inlined]
  [6] save(filename::String, td::PGFPlotsX.TikzDocument; include_preamble::Bool, latex_engine::PGFPlotsX.LaTeXEngine, buildflags::Vector{String}, dpi::Int64, showing_ide::Bool)
    @ PGFPlotsX C:\Users\pty\.julia\packages\PGFPlotsX\78BAg\src\tikzdocument.jl:84
  [7] show(f::IOBuffer, #unused#::MIME{Symbol("image/svg+xml")}, td::PGFPlotsX.TikzDocument)
    @ PGFPlotsX C:\Users\pty\.julia\packages\PGFPlotsX\78BAg\src\tikzdocument.jl:294
  [8] _show(io::IOBuffer, mime::MIME{Symbol("image/svg+xml")}, plt::Plots.Plot{Plots.PGFPlotsXBackend})
    @ Plots C:\Users\pty\.julia\packages\Plots\esM5q\src\backends\pgfplotsx.jl:1364
  [9] #invokelatest#2
    @ .\essentials.jl:816 [inlined]
 [10] invokelatest
    @ .\essentials.jl:813 [inlined]
 [11] show
    @ C:\Users\pty\.julia\packages\Plots\esM5q\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#8
    @ C:\Applications\Julia-1.9.0\share\julia\stdlib\v1.9\Base64\src\Base64.jl:44 [inlined]
 [15] stringmime
    @ C:\Applications\Julia-1.9.0\share\julia\stdlib\v1.9\Base64\src\Base64.jl:44 [inlined]
 [16] display(d::VSCodeServer.InlineDisplay, m::MIME{Symbol("image/svg+xml")}, x::Plots.Plot{Plots.PGFPlotsXBackend})
    @ VSCodeServer c:\Users\pty\.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\display.jl:57
 [17] display(d::VSCodeServer.InlineDisplay, mime::String, x::Any)
    @ Base.Multimedia .\multimedia.jl:228
 [18] display(d::VSCodeServer.InlineDisplay, x::Plots.Plot{Plots.PGFPlotsXBackend})
    @ VSCodeServer c:\Users\pty\.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\display.jl:166
 [19] display(x::Any)
    @ Base.Multimedia .\multimedia.jl:340
 [20] #invokelatest#2
    @ .\essentials.jl:816 [inlined]
 [21] invokelatest
    @ .\essentials.jl:813 [inlined]
 [22] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL C:\Applications\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:305
 [23] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL C:\Applications\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:287
 [24] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Applications\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:557
 [25] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL C:\Applications\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:285
 [26] (::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 C:\Applications\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:899
 [27] (::VSCodeServer.var"#98#101"{REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt}})(mi::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
    @ VSCodeServer c:\Users\pty\.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\repl.jl:122
 [28] #invokelatest#2
    @ .\essentials.jl:816 [inlined]
 [29] invokelatest
    @ .\essentials.jl:813 [inlined]
 [30] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Applications\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\LineEdit.jl:2647
 [31] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Applications\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:1300
 [32] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL .\task.jl:514