Search code examples
juliahistogram

UndefVarError: histogram not defined in Julia


I am trying to draw histogram as following :

using Plots; using PyPlot
pyplot() # Plots.PyPlotBackend()
x = 0:100;
result = rand(x,2000);
histogram(result)

However, it returns UndefVarError :

UndefVarError: histogram not defined

Stacktrace:
 [1] top-level scope
   @ In[156]:5
 [2] eval
   @ .\boot.jl:360 [inlined]
 [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base .\loading.jl:1116

I followed Plotting a histogram in Julia but returns the error.

How can I resolve the error?


Solution

  • I am unable to re-produce this error in Julia 1.6.3. When I run:

    julia> using Plots; using PyPlot
    
    julia> pyplot() # Plots.PyPlotBackend()
    Plots.PyPlotBackend()
    
    julia> x = 0:100;
    
    julia> result = rand(x,2000);
    
    julia> histogram(result)
    
    

    I get:

    Histogram image

    Without any errors. This also works without running using PyPlot for me.