# Plots (PyPlot) xscale=log throwing error

**URL:** <https://discourse.julialang.org/t/plots-pyplot-xscale-log-throwing-error/28093>\
**Category:** New to Julia\
**Created:** [August 28, 2019, 9:13am UTC](https://discourse.julialang.org/t/plots-pyplot-xscale-log-throwing-error/28093 "2019-08-28T09:13:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rouzaire](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@Rouzaire](https://discourse.julialang.org/u/Rouzaire)\
**Post date:** [August 28, 2019, 9:13am UTC](https://discourse.julialang.org/t/plots-pyplot-xscale-log-throwing-error/28093/1 "2019-08-28T09:13:59Z")

</div>

Hello,

Here is my code :

```julia
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 :

```julia
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
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

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [August 29, 2019, 1:48am UTC](https://discourse.julialang.org/t/plots-pyplot-xscale-log-throwing-error/28093/2 "2019-08-29T01:48:01Z")

</div>

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

```julia
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!

---

<div class="post-metadata">

**Author:** ![Rouzaire](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@Rouzaire](https://discourse.julialang.org/u/Rouzaire)\
**Post date:** [August 29, 2019, 8:12am UTC](https://discourse.julialang.org/t/plots-pyplot-xscale-log-throwing-error/28093/3 "2019-08-29T08:12:07Z")

</div>

Thanks !

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [August 29, 2019, 10:19am UTC](https://discourse.julialang.org/t/plots-pyplot-xscale-log-throwing-error/28093/4 "2019-08-29T10:19:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Rouzaire](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@Rouzaire](https://discourse.julialang.org/u/Rouzaire)\
**Post date:** [August 29, 2019, 11:24am UTC](https://discourse.julialang.org/t/plots-pyplot-xscale-log-throwing-error/28093/5 "2019-08-29T11:24:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [August 29, 2019, 11:40am UTC](https://discourse.julialang.org/t/plots-pyplot-xscale-log-throwing-error/28093/6 "2019-08-29T11:40:44Z")

</div>

> [@Rouzaire](#):
>
> How do you properly open an issue ? Never done that before.

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](https://github.com/JuliaPy/PyPlot.jl), 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](https://stackoverflow.com/questions/47850202/plotting-a-histogram-on-a-log-scale-with-matplotlib#47850787) that this should be possible with the underlying matplotlib library.

---

<div class="post-metadata">

**Author:** ![daschw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daschw/32/2926_2.png) [@daschw](https://discourse.julialang.org/u/daschw)\
**Post date:** [August 29, 2019, 12:19pm UTC](https://discourse.julialang.org/t/plots-pyplot-xscale-log-throwing-error/28093/7 "2019-08-29T12:19:01Z")

</div>

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](https://github.com/JuliaPlots/Plots.jl/pull/2167).

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [August 29, 2019, 1:07pm UTC](https://discourse.julialang.org/t/plots-pyplot-xscale-log-throwing-error/28093/8 "2019-08-29T13:07:33Z")

</div>

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 😛
