JuliaPlots / Plots.jl

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

`ticks=false` doesn't work with certain themes #2731

Open VPetukhov opened 4 years ago

VPetukhov commented 4 years ago

For themes ggplot2, bright, vibrant and mute, ticks=false results in the error "MethodError: no method matching getindex(::Nothing, ::Int64)"

Example:

import Plots
Plots.theme(:mute)
Plots.scatter(1:100, ticks=false)

Package versions: PlotThemes v2.0.0 and Plots v1.3.3. Looks similar to https://github.com/JuliaPlots/Plots.jl/issues/2431.

BeastyBlacksmith commented 4 years ago

The problem here is that it tries to compute the gridlines with no ticks given. While this could be handled more gracefully, I wonder if that really is what you are after. Was your intent to not show the ticklabels? That might be better archived by using showaxis = false

VPetukhov commented 4 years ago

Thanks for the answer! I'm indeed trying to hide ticks, but I need to do it only for the x axis. So in the existing way I do it as Plots.scatter(1:100, xticks=false), and it works fine. According to the manual, it should be possible to do with showaxis=:y, but it throws the error:

TypeError: non-boolean (Symbol) used in boolean context

Stacktrace:
 [1] axis_drawing_info(::Plots.Subplot{Plots.GRBackend}) at /home/vpetukhov/.julia/packages/Plots/ninUP/src/axes.jl:606
 [2] gr_display(::Plots.Subplot{Plots.GRBackend}, ::Measures.Length{:mm,Float64}, ::Measures.Length{:mm,Float64}, ::Array{Float64,1}) at /home/vpetukhov/.julia/packages/Plots/ninUP/src/backends/gr.jl:1352
 [3] gr_display(::Plots.Plot{Plots.GRBackend}, ::String) at /home/vpetukhov/.julia/packages/Plots/ninUP/src/backends/gr.jl:673
 [4] _show(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("image/svg+xml")}, ::Plots.Plot{Plots.GRBackend}) at /home/vpetukhov/.julia/packages/Plots/ninUP/src/backends/gr.jl:1947
 [5] show(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("image/svg+xml")}, ::Plots.Plot{Plots.GRBackend}) at /home/vpetukhov/.julia/packages/Plots/ninUP/src/output.jl:215
 [6] #sprint#339(::Nothing, ::Int64, ::typeof(sprint), ::Function, ::MIME{Symbol("image/svg+xml")}, ::Vararg{Any,N} where N) at ./strings/io.jl:105
 [7] sprint(::Function, ::MIME{Symbol("image/svg+xml")}, ::Vararg{Any,N} where N) at ./strings/io.jl:101
 [8] _ijulia_display_dict(::Plots.Plot{Plots.GRBackend}) at /home/vpetukhov/.julia/packages/Plots/ninUP/src/ijulia.jl:53
 [9] display_dict(::Plots.Plot{Plots.GRBackend}) at /home/vpetukhov/.julia/packages/Plots/ninUP/src/init.jl:81

Am I doing something wrong, or should I submit it as a separate issue?

BeastyBlacksmith commented 4 years ago

that is a bug, I am fixing it in https://github.com/JuliaPlots/Plots.jl/pull/2733

ashwani-rathee commented 4 years ago

@BeastyBlacksmith is this issue still worked upon or has it been worked out??

BeastyBlacksmith commented 4 years ago

showaxis is working as advertised since Plots 1.3.5

BeastyBlacksmith commented 4 years ago

the issue in the OP is unresolved as far as I know, though