JuliaPlots / StatsPlots.jl

Statistical plotting recipes for Plots.jl
Other
437 stars 88 forks source link

using log10 scale with negative numbers breaks log scales forever #383

Open HenriDeh opened 4 years ago

HenriDeh commented 4 years ago

If you attempt to make a plot with a logarithmic scale and negative numbers, instead of throwing a domain error, some warnings are thrown and an almost empty plot is created. If you then correct the data to be all positive, the returned plot is still messed up and the only way to make it right is to restart julia.

using StatsPlots, DataFrames

df = DataFrame(a = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2], b = repeat([-0.1, 0.1],5))

boxplot(df.a, df.b, yscale = :log10)
┌ Warning: No strict ticks found
└ @ PlotUtils C:\Users\Henri\.julia\packages\PlotUtils\NS6Tf\src\ticks.jl:283
┌ Warning: No strict ticks found
└ @ PlotUtils C:\Users\Henri\.julia\packages\PlotUtils\NS6Tf\src\ticks.jl:283
┌ Warning: No strict ticks found
└ @ PlotUtils C:\Users\Henri\.julia\packages\PlotUtils\NS6Tf\src\ticks.jl:283

boxplot(df.a, max.(0.01, df.b), yscale = :log10)
GKS: Rectangle definition is invalid in routine SET_VIEWPORT

the second boxplot returns this: image

mkborregaard commented 3 years ago

This is only with the GR backend, right?

HenriDeh commented 3 years ago

Yes, with pyplots the first attempt throws an error and the corrected data works fine.