Problem with ylims in Plots

I have problems with the ylims option of plots, in particular when i want to crop very big values of the input vector MWE:

julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, haswell)

(@v1.5) pkg> status Plots
Status `C:\Users\Dictino\.julia\environments\v1.5\Project.toml`
  [91a5bcdd] Plots v1.5.8

julia> using Plots

julia> gr()
Plots.GRBackend()

julia> plot([1,2,3,10^17],ylims=(0,10))

Works perfectly

image

But

julia> plot([1,2,3,10^18],ylims=(0,10))

Plots nothing:

image

Without the ylims it also works fine.

Is there an overflow or some other bug when applying the ylims? which is the better way to do this?

I have a workarround, just saturate the values of the vector before plotting… But I’m curious why it does not work and if it exists a better option to solve this.

Best,
Dictino

try update Plots.jl? it looks the same for me in both cases

1 Like

Thanks for the advice!

I’ve created a new test environment with Plots v1.7.3 but I have the same issue…

not sure what’s the exact issue then, I’m on v1.7.3 as well and I can see the second plot

you may want to make sure you’re actually plotting with that version though

I use Julia 1.4.2 on my home computer. If I add the ylims keyword, nothing is plotted whether I use 10^17 or 10^18 – when I use the gr() back-end.

If I switch to the pyplot() back-end, the plot is displayed, even when I add the ylims keyword.

1 Like

Thanks, @BLI
It also works with Plotly for me, mabye is a GR bug…

How can I do it?

This is what I did on a fresh REPL:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _ |  |
  | | |_| | | | (_| |  |  Version 1.5.0 (2020-08-01)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> mkdir("test")
"test"

julia> cd("test")

(@v1.5) pkg> activate .
 Activating new environment at `C:\Users\Dictino\test\Project.toml`

(test) pkg> add Plots
   Updating registry at `C:\Users\Dictino\.julia\registries\General`
  Resolving package versions...
Updating `C:\Users\Dictino\test\Project.toml`
  [91a5bcdd] + Plots v1.7.3
Updating `C:\Users\Dictino\test\Manifest.toml`
  [79e6a3ab] + Adapt v2.3.0
  [56f22d72] + Artifacts v1.3.0
  [6e34b625] + Bzip2_jll v1.0.6+5
  [35d6a980] + ColorSchemes v3.10.1
  [3da002f7] + ColorTypes v0.10.9
  [5ae59095] + Colors v0.12.4
  [34da2185] + Compat v3.23.0
  [d38c429a] + Contour v0.5.5
  [9a962f9c] + DataAPI v1.4.0
  [864edb3b] + DataStructures v0.18.8
  [e2d170a0] + DataValueInterfaces v1.0.0
  [5ae413db] + EarCut_jll v2.1.5+0
  [c87230d0] + FFMPEG v0.4.0
  [b22a6f82] + FFMPEG_jll v4.3.1+4
  [53c48c17] + FixedPointNumbers v0.8.4
  [59287772] + Formatting v0.4.1
  [d7e528f0] + FreeType2_jll v2.10.1+5
  [559328eb] + FriBidi_jll v1.0.5+6
  [28b8d3ca] + GR v0.52.0
  [5c1252a2] + GeometryBasics v0.3.3
  [4d00f742] + GeometryTypes v0.8.3
  [42e2da0e] + Grisu v1.0.0
  [cd3eb016] + HTTP v0.8.19
  [83e8ac13] + IniFile v0.5.0
  [c8e1da08] + IterTools v1.3.0
  [82899510] + IteratorInterfaceExtensions v1.0.0
  [692b3bcd] + JLLWrappers v1.1.3
  [682c06a0] + JSON v0.21.1
  [c1c5ebd0] + LAME_jll v3.100.0+3
  [b964fa9f] + LaTeXStrings v1.2.0
  [23fbe1c1] + Latexify v0.14.2
  [dd192d2f] + LibVPX_jll v1.9.0+1
  [1914dd2f] + MacroTools v0.5.6
  [739be429] + MbedTLS v1.0.3
  [c8ffd9c3] + MbedTLS_jll v2.16.8+1
  [442fdcdd] + Measures v0.3.1
  [e1d29d7a] + Missings v0.4.4
  [77ba4419] + NaNMath v0.3.4
  [e7412a2a] + Ogg_jll v1.3.4+2
  [458c3c95] + OpenSSL_jll v1.1.1+6
  [91d4177d] + Opus_jll v1.3.1+3
  [bac558e1] + OrderedCollections v1.3.2
  [69de0a69] + Parsers v1.0.11
  [ccf2f8ad] + PlotThemes v2.0.0
  [995b91a9] + PlotUtils v1.0.7
  [91a5bcdd] + Plots v1.7.3
  [3cdcf5f2] + RecipesBase v1.1.0
  [01d81517] + RecipesPipeline v0.1.13
  [189a3867] + Reexport v0.2.0
  [ae029012] + Requires v1.1.0
  [6c6a2e73] + Scratch v1.0.3
  [992d4aef] + Showoff v0.3.2
  [a2af1166] + SortingAlgorithms v0.3.1
  [90137ffa] + StaticArrays v0.12.5
  [2913bbd2] + StatsBase v0.33.2
  [09ab397b] + StructArrays v0.4.4
  [3783bdb8] + TableTraits v1.0.0
  [bd369af6] + Tables v1.1.0
  [83775a58] + Zlib_jll v1.2.11+18
  [0ac62f75] + libass_jll v0.14.0+4
  [f638f0a6] + libfdk_aac_jll v0.1.6+4
  [f27f6e37] + libvorbis_jll v1.3.6+6
  [1270edf5] + x264_jll v2020.7.14+2
  [dfaa095f] + x265_jll v3.0.0+3
  [2a0f44e3] + Base64
  [ade2ca70] + Dates
  [8bb1440f] + DelimitedFiles
  [8ba89e20] + Distributed
  [b77e0a4c] + InteractiveUtils
  [76f85450] + LibGit2
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [a63ad114] + Mmap
  [44cfe95a] + Pkg
  [de0858da] + Printf
  [3fa0cd96] + REPL
  [9a3f8284] + Random
  [ea8e919c] + SHA
  [9e88b42a] + Serialization
  [1a1011a3] + SharedArrays
  [6462fe0b] + Sockets
  [2f01184e] + SparseArrays
  [10745b16] + Statistics
  [8dfed614] + Test
  [cf7118a7] + UUIDs
  [4ec0a83e] + Unicode

(test) pkg> status Plots
Status `C:\Users\Dictino\test\Project.toml`
  [91a5bcdd] Plots v1.7.3

julia> using Plots

julia> plot([1,2,3,10^18],ylims=(0,10))

And nothing is displayed on the plot.

“activate” does not de-activate your home environment, sometimes this causes error

Ups, then I misunderstood how activate works…
I guessed that activating this test environment will enforce julia to use Plots v1.7.3.

What else can I do to know for sure what version of Plots I’m using?

Now I’m sure that I was using Plots v1.7.3 (I just remove the other versions from the packages folder)
I will post an issue on Plots.jl.
Thank you for your help @jling and @BLI!