using both plt.hist and base.hist

129 views
Skip to first unread message

samuel....@gmail.com

unread,
Feb 18, 2015, 1:47:27 PM2/18/15
to julia...@googlegroups.com
Hi,

Once I've loaded pyplot, I can't figure out how to use the base.hist function. What is the workaround?

help(base.hist) returns the plt.hist functionality.

Kevin Squire

unread,
Feb 18, 2015, 4:58:13 PM2/18/15
to julia...@googlegroups.com
Hi Sam,

Just to be clear, you're using PyPlot.jl in Julia, right?  The way you wrote the code above doesn't actually run in Julia ("base" is "Base" and "plt" is "PyPlot"--did you alias those?), and I want to make sure that you're not doing something like, e.g., using Python and loading pyjulia.

Anyway, assuming that's true...

It's unfortunate that the help is overwritten (might be worth opening an issue in PyPlot.jl), but in fact, the version in Base is still working just fine.  In fact, I don't see a way to call the version in PyPlot without using "PyPlot.hist":

julia> using PyPlot
Warning: Method definition eltype(Any,) in module Base at abstractarray.jl:10 overwritten in module Compat at /Users/kevin/.julia/v0.3/Compat/src/Compat.jl:163.
INFO: Loading help data...

julia> hist
hist (generic function with 6 methods)

julia> hist(rand(1:10, 100))    #calls the Base version
(0.0:2.0:10.0,[18,14,21,18,29])

julia> @which hist(rand(1:10, 100))
hist(v::AbstractArray{T,1}) at statistics.jl:599

julia> @which PyPlot.hist(rand(1:10, 100))
hist(args...) at /Users/kevin/.julia/v0.3/PyPlot/src/PyPlot.jl:367

Cheers,
   Kevin

David P. Sanders

unread,
Feb 19, 2015, 1:42:02 PM2/19/15
to julia...@googlegroups.com


El miércoles, 18 de febrero de 2015, 15:58:13 (UTC-6), Kevin Squire escribió:
Hi Sam,

Just to be clear, you're using PyPlot.jl in Julia, right?  The way you wrote the code above doesn't actually run in Julia ("base" is "Base" and "plt" is "PyPlot"--did you alias those?), and I want to make sure that you're not doing something like, e.g., using Python and loading pyjulia.

Actually, the Julia `PyPlot` package automatically provides an alias `plt` for closer compatibility with how `matplotlib` is typically used in Python.

David.

Kevin Squire

unread,
Feb 19, 2015, 3:28:30 PM2/19/15
to julia...@googlegroups.com
Didn't know that--thanks for the info!
Reply all
Reply to author
Forward
0 new messages