Plots (PyPlot) xscale=log throwing error

Hello,

Here is my code :

x = abs.(randn(100000))
plotly()
Plots.histogram(x, yaxis = (:log10, (1,Inf))) # line A
Plots.histogram(log.(x))  # line B
Plots.histogram(x, xaxis = (:log10, (1,Inf)))  # line C

Lines A and B work properly. Line C, with Pyplot backend (and not with plotly for instance) throw the following error :

PyError ($(Expr(:escape, :(ccall(#= C:\Users\Rouzaire\.julia\packages\PyCall\ttONZ\src\pyfncall.jl:44 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'ValueError'>
ValueError("'linthreshx/linthreshy' must be positive",)
  File "C:\Users\Ylann Rouzaire\.julia\conda\3\lib\site-packages\matplotlib\axes\_base.py", line 3322, in set_xscale
    ax.xaxis._set_scale(value, **kwargs)
  File "C:\Users\Ylann Rouzaire\.julia\conda\3\lib\site-packages\matplotlib\axis.py", line 799, in _set_scale
    self._scale = mscale.scale_factory(value, self, **kwargs)
  File "C:\Users\Ylann Rouzaire\.julia\conda\3\lib\site-packages\matplotlib\scale.py", line 743, in scale_factory
    return _scale_mapping[scale](axis, **kwargs)
  File "C:\Users\Ylann Rouzaire\.julia\conda\3\lib\site-packages\matplotlib\scale.py", line 595, in __init__
    raise ValueError("'linthreshx/linthreshy' must be positive")

Various Informations :

julia> Pkg.status("PyPlot")
    Status `C:\Users\Rouzaire\.julia\environments\v1.1\Project.toml`
  [d330b81b] PyPlot v2.8.1

Julia Version 1.1.1
OS: Windows 10

FYI, it looks like you’re using quoting intended for speech rather than code. You want to use 3 backticks at the top and bottom of code blocks or press the button that looks like </>. Compare

function foo(speech)
println(“this doesn’t look good”)
end

to

function bar(code)
    println("ahh, much better")
end

You can still edit your post to fix.

Alas, I don’t have anything constructive to say about your actual question. Hopefully someone else will be along soon!

Thanks !

1 Like

Given that this works with other backends, AND it works with the yaxis, I think it might be worth opening an issue with PyPlot. Does it work if you give a finite upper limit?

Does it work if you give a finite upper limit ? → No, it does not.

How do you properly open an issue ? Never done that before.
Thanks

Welcome to open source! You’ve already got a nice example of code that produces the problem - I’d make it a full MWE (minimum working example), including the using Plots so that someone can open a REPL and just copy-paste your code, and just basically include the same thing that’s in your first post.

To open the issue, just go to the GitHub page, click the issues tab, and then “new issue.” It’s probably worth searching through the issues there to see if anyone else has reported it before hand. If they have, you can add your example if it might be helpful.

Come to think of it, I’m actually not sure of it makes more sense to open the issue on the PyPlot repo or the Plots repo it could be an issue with the backend code itself, which would mean the latter.

If it were me, I’d see if I could reproduce the issue with PyPlot alone. A quick Google search suggests that this should be possible with the underlying matplotlib library.

2 Likes

It’s not a PyPlot issue, it’s a Plots pyplot backend issue and hopefully fixed with https://github.com/JuliaPlots/Plots.jl/pull/2167.

1 Like

So then @Rouzaire no issue needed. To peel back the curtain a bit, I posted a link to this discourse thread in the #plotting channel on slack, which in some cases is just as good as opening an issue :stuck_out_tongue: