JuliaPlots / Plots.jl

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

scientific formatter doesnt work with matplotlib 1.5 - upgrade needed #715

Closed floswald closed 7 years ago

floswald commented 7 years ago

hi,

i get this:

using Plots
plot(rand(100)*1e7,yformatter=:scientific)

figure_1

thanks

mkborregaard commented 7 years ago

So this works perfect in my pyplot. It looks like you are on an old version of PyPlot too? (I am on 2.3.1). Fails on GR though:

Error showing value of type Plots.Plot{Plots.GRBackend}:
ERROR: BoundsError: attempt to access 7-element Array{UInt8,1} at index [8]
 in setindex!(::Array{UInt8,1}, ::Int64, ::Int64) at ./array.jl:415
 in setindex!(::Array{UInt8,1}, ::Int64, ::Int64) at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
 in latin1(::String) at /Users/michael/.julia/v0.5/GR/src/GR.jl:461
 in text at /Users/michael/.julia/v0.5/GR/src/GR.jl:493 [inlined]
 in gr_text(::Float64, ::Float64, ::String) at /Users/michael/.julia/v0.5/Plots/src/backends/gr.jl:195
 in gr_display(::Plots.Subplot{Plots.GRBackend}, ::Measures.Length{:mm,Float64}, ::Measures.Length{:mm,Float64}, ::Array{Float64,1}) at /Users/michael/.julia/v0.5/Plots/src/backends/gr.jl:685
 in gr_display(::Plots.Plot{Plots.GRBackend}) at /Users/michael/.julia/v0.5/Plots/src/backends/gr.jl:498
 in _display(::Plots.Plot{Plots.GRBackend}) at /Users/michael/.julia/v0.5/Plots/src/backends/gr.jl:1118
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::Plots.Plot{Plots.GRBackend}) at /Users/michael/.julia/v0.5/Plots/src/output.jl:138
 in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::Plots.Plot{Plots.GRBackend}) at ./REPL.jl:135
 in display(::Plots.Plot{Plots.GRBackend}) 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_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
 in run_frontend(::Base.REPL.LineEditREPL, ::Base.REPL.REPLBackendRef) at ./REPL.jl:903
 in run_repl(::Base.REPL.LineEditREPL, ::Base.##950#951) at ./REPL.jl:188
 in _start() at ./client.jl:363
 in _start() at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
floswald commented 7 years ago

i am on 2.3.1.

julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, broadwell)

julia> Pkg.status()
46 required packages:
 - ApproxFun                     0.5.0
 - Atom                          0.5.9
 - BenchmarkTools                0.0.7
 - Blink                         0.5.1
 - Cairo                         0.2.35
 - Coverage                      0.3.2
 - DataFrames                    0.8.5
 - DataFramesMeta                0.1.3
 - Debug                         0.1.6
 - DifferentialEquations         1.8.0
 - Documenter                    0.9.0
 - Example                       0.4.1              526e34fd (dirty)
 - FactCheck                     0.4.3
 - FastGaussQuadrature           0.1.0
 - FixedSizeArrays               0.2.5
 - ForwardDiff                   0.3.4
 - FreqTables                    0.0.2
 - GLM                           0.6.1
 - GR                            0.19.0+            master
 - Gallium                       0.0.4
 - HDF5                          0.7.3
 - Homebrew                      0.4.2
 - IJulia                        1.4.1
 - Interpolations                0.3.7
 - JLD                           0.6.9
 - JSON                          0.8.3
 - Logging                       0.3.1
 - Lumberjack                    2.1.0
 - NullableArrays                0.1.0
 - NumericExtensions             0.6.2
 - Optim                         0.7.7
 - ParallelAccelerator           0.2.2
 - PlotlyJS                      0.5.2
 - Plots                         0.10.3
 - ProfileView                   0.1.5
 - PyPlot                        2.3.1
 - Query                         0.3.1
 - RCall                         0.6.4
 - RData                         0.0.4
 - RDatasets                     0.2.0
 - Rmath                         0.1.6
 - Roots                         0.3.0
 - Rsvg                          0.0.2
 - Sobol                         0.2.0
 - StatPlots                     0.2.1
 - Yeppp                         0.1.0
164 additional packages:
 - ASTInterpreter                0.0.4
 - AbstractTrees                 0.0.4
 - AlgebraicDiffEq               0.1.0
 - ApproXD                       0.0.0-             v0.5 (unregistered)
 - ArgParse                      0.4.0
 - ArrayViews                    0.6.4
 - AxisAlgorithms                0.1.6
 - AxisArrays                    0.0.4
 - BandedMatrices                0.2.1
 - BaseTestNext                  0.2.2
 - BinDeps                       0.4.7
 - Blosc                         0.2.0
 - BufferedStreams               0.3.0
 - COFF                          0.0.2
 - CRC                           1.2.0
 - Calculus                      0.2.0
 - CatIndices                    0.0.2
 - CategoricalArrays             0.1.2
 - ChunkedArrays                 0.1.1
 - CodeTools                     0.4.3
 - Codecs                        0.3.0
 - ColorTypes                    0.3.4
 - ColorVectorSpace              0.4.0
 - Colors                        0.7.3
 - Combinatorics                 0.3.2
 - Compat                        0.19.0
 - CompilerTools                 0.2.1
 - ComputationalResources        0.0.2
 - Conda                         0.5.1
 - CoordinateTransformations     0.4.0
 - Copulas                       0.0.0-             master (unregistered)
 - CustomUnitRanges              0.0.4
 - DWARF                         0.1.0
 - DataArrays                    0.3.12
 - DataStructures                0.5.3
 - DelayDiffEq                   0.1.0
 - DiffBase                      0.0.4
 - DiffEqBase                    0.11.0
 - DiffEqBiological              0.0.1
 - DiffEqCallbacks               0.0.1
 - DiffEqDevTools                0.6.0
 - DiffEqFinancial               0.0.1
 - DiffEqJump                    0.1.0
 - DiffEqMonteCarlo              0.0.1
 - DiffEqPDEBase                 0.0.3
 - DiffEqParamEstim              0.1.0
 - DiffEqSensitivity             0.0.4
 - Distances                     0.4.1
 - Distributions                 0.12.1
 - DocOpt                        0.2.1
 - DocStringExtensions           0.3.1
 - DualNumbers                   0.2.3
 - ELF                           0.1.0
 - EllipsisNotation              0.0.2
 - FFTViews                      0.0.2
 - FastTransforms                0.0.7
 - FileIO                        0.3.0
 - FiniteElementDiffEq           0.2.1
 - FixedPointNumbers             0.3.4
 - FunctionWrappers              0.0.1
 - GZip                          0.2.20
 - GenericSVD                    0.0.2
 - Git                           0.1.0
 - Graphics                      0.1.4
 - Gtk                           0.11.0
 - GtkUtilities                  0.2.2
 - Hiccup                        0.1.1
 - HttpCommon                    0.2.6
 - HttpParser                    0.2.0
 - HttpServer                    0.1.7
 - ImageAxes                     0.1.1
 - ImageCore                     0.1.4
 - ImageFiltering                0.1.2
 - ImageMetadata                 0.2.1
 - ImageTransformations          0.1.0
 - Images                        0.8.0
 - IndirectArrays                0.1.1
 - InplaceOps                    0.1.0
 - IntervalSets                  0.0.3
 - IterativeSolvers              0.2.2
 - Iterators                     0.3.0
 - JuliaParser                   0.7.4
 - Juno                          0.2.7
 - KernelDensity                 0.3.1
 - LNR                           0.0.2
 - LaTeXStrings                  0.2.0
 - Lazy                          0.11.5
 - LearnBase                     0.1.2
 - LegacyStrings                 0.2.0
 - Libz                          0.2.4
 - LineSearches                  0.1.5
 - LossFunctions                 0.0.3
 - LsqFit                        0.2.0
 - MOpt                          0.0.0-             mvnorm (unregistered)
 - MachO                         0.0.4
 - MacroTools                    0.3.6
 - MappedArrays                  0.0.6
 - MbedTLS                       0.4.3
 - Measures                      0.0.3
 - Media                         0.2.5
 - Mocking                       0.3.2
 - MultiScaleArrays              0.1.0
 - Mustache                      0.1.3
 - Mux                           0.2.3
 - NLsolve                       0.9.1
 - NaNMath                       0.2.2
 - NamedArrays                   0.5.3
 - NamedTuples                   1.0.0
 - Nettle                        0.3.0
 - NumericFuns                   0.2.4
 - ObjFileBase                   0.0.4
 - OffsetArrays                  0.2.14
 - OrdinaryDiffEq                1.4.0
 - PDMats                        0.5.6
 - ParameterizedFunctions        1.0.0
 - Parameters                    0.6.0
 - PlotThemes                    0.1.1
 - PlotUtils                     0.3.0
 - PolynomialFactors             0.0.3
 - Polynomials                   0.1.3
 - PositiveFactorizations        0.0.4
 - Primes                        0.1.2
 - PyCall                        1.10.0
 - QuadGK                        0.1.1
 - RangeArrays                   0.1.2
 - Ranges                        0.0.1
 - Ratios                        0.0.4
 - Reactive                      0.3.7
 - RecipesBase                   0.1.0
 - RecursiveArrayTools           0.2.0
 - Reexport                      0.0.3
 - Requests                      0.4.1
 - Requires                      0.3.0
 - ResettableStacks              0.1.0
 - Rotations                     0.3.5
 - SHA                           0.3.1
 - SIUnits                       0.1.0
 - ShowItLikeYouBuildIt          0.0.1
 - Showoff                       0.0.7
 - SimpleTraits                  0.3.0
 - SortingAlgorithms             0.1.0
 - SpecialFunctions              0.1.1
 - StackTraces                   0.1.1
 - StaticArrays                  0.3.0
 - StatsBase                     0.13.1
 - StatsFuns                     0.4.0
 - StochasticDiffEq              1.1.0
 - StokesDiffEq                  0.1.0
 - StructIO                      0.0.2
 - Sundials                      0.7.0
 - SymEngine                     0.1.3
 - TerminalUI                    0.0.2
 - TestSetExtensions             0.0.2+             master
 - TexExtensions                 0.0.3
 - TextWrap                      0.1.6
 - TiledIteration                0.0.2
 - ToeplitzMatrices              0.2.0
 - URIParser                     0.1.8
 - VT100                         0.1.0
 - VectorizedRoutines            0.0.2
 - WebSockets                    0.2.1
 - WoodburyMatrices              0.2.2
 - ZMQ                           0.4.1
mkborregaard commented 7 years ago

Could you try Plots master?

floswald commented 7 years ago

I get this on master:

julia> using Plots

julia> pyplot()
Plots.PyPlotBackend()

julia> plot(rand(100)*1e7,yformatter=:scientific)
Error showing value of type Plots.Plot{Plots.PyPlotBackend}:
ERROR: KeyError: key "set_facecolor" not found
floswald commented 7 years ago

just to confirm, on the latest release I get a plot window, on master i get this error.

mkborregaard commented 7 years ago

What is your version of matplotlib? It should be 2.0.0

floswald commented 7 years ago

how can i check that?

julia> PyPlot.matplotlib
PyObject <module 'matplotlib' from '/Users/florian.oswald/.julia/v0.5/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/__init__.pyc'>
mkborregaard commented 7 years ago

Look in your conda distribution?

mkborregaard commented 7 years ago

conda list in a terminal (on mac)

floswald commented 7 years ago

I have a Conda.jl installation, no systemwide. matplotlib installed only inside julia.

ok i'm getting there. i see in /Users/florian.oswald/.julia/v0.5/Conda/deps/usr/lib/python2.7/site-packages/

matplotlib-1.5.1-py2.7.egg-info
matplotlib

and i deduce that i have version 1.5? how to update this?

mkborregaard commented 7 years ago

Try and open an issue on PyPlot, this is not Plots-related.

tbreloff commented 7 years ago

To be fair, this should be conditional on matplotlib version. There must be a way to check this and set a constant during init.

On Mon, Mar 13, 2017 at 7:03 AM Michael Krabbe Borregaard < notifications@github.com> wrote:

Closed #715 https://github.com/JuliaPlots/Plots.jl/issues/715.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JuliaPlots/Plots.jl/issues/715#event-997019662, or mute the thread https://github.com/notifications/unsubscribe-auth/AA492uwX6YO9jLV2MOwhJEXnQL8x9-Faks5rlSJxgaJpZM4MSHHJ .

mkborregaard commented 7 years ago

Good idea. After spending all my julia time for a week unsuccessfully hunting down the bug that makes pyplot calls fail when marker_z is specified I have given up on trying to fix the pyplot backend without help, and feel rather disillusioned about contributing to Plots in general. The set_facecolor call in pyplot.jl line 1078 would have to be made conditional on version, as that does not work in 1.5.

mkborregaard commented 7 years ago

So @floswald if it was premature to close the issue - reopening.

floswald commented 7 years ago

matplotlib update using Conda; Conda.update() did the job. this works on the latest Plots release. i upgraded to matplotlib 2.0.

i see the warning

sys:1: MatplotlibDeprecationWarning: The set_axis_bgcolor function was deprecated in version 2.0. Use set_facecolor instead.

figure_1-1

@mkborregaard don't get disillusioned please!

mkborregaard commented 7 years ago

Thanks, sorry for bringing that up. Great that you have it working!

tbreloff commented 7 years ago

After spending all my julia time for a week unsuccessfully hunting down the bug that makes pyplot calls fail when marker_z is specified I have given up on trying to fix the pyplot backend without help, and feel rather disillusioned about contributing to Plots in general.

Word. Imagine how I feel. PyPlot should be deprecated unless someone steps up to keep it alive.