L.J
L.J

Reputation: 1084

Plot not defined with Julia

I compiled Julia 0.1 from the source code on my Ubuntu 12.04. It is my first time try with Julia actually.

The compilation got through to the end with no problem but some warnings.

When I try to execute the plot command , here comes the problem,

    julia> plot(x->sin(x^2)/x, -2pi,2pi)
    ERROR: plot not defined

Did the compilation go wrong somewhere or Do I have to install extra package to plot in Julia?

Upvotes: 13

Views: 21923

Answers (4)

saolof
saolof

Reputation: 1661

As of right now (a few years passed since the question was asked so the ecosystem has matured), the package I would suggest for easy quick plots would be Gadfly, with some use of PyPlot for publication quality graphs that require a lot of control.

To install, just type

Pkg.add("Gadfly")

in a Julia command line, and to use, type:

using Gadfly
plot([sin, cos], 0, 25)

PyPlot is still the preferred plotting option for when you want a lot of control over your graphs, but it is a wrapper for a Python library and is slightly less user-friendly. It also requires a working python install on your system.

Upvotes: 0

Markus Kuhn
Markus Kuhn

Reputation: 1042

For MATLAB-style plotting under Julia, type once

Pkg.add("PyPlot")

to install the PyPlot package, which gives you access to Python's matplotlib library. Then try e.g.

using PyPlot
x = -2pi:0.1:2pi;
plot(x, sin(x.^2)./x);

Upvotes: 9

Keno Fischer
Keno Fischer

Reputation: 1405

The web-based graphics are outdated and unmaintained (though there's work in progress to get the next generation of web graphics working). Plotting alternatives include the Winston or Gadfly packages at https://github.com/nolta/Winston.jl and https://github.com/dcjones/Gadfly.jl which you can install simply using the Pkg.add("Winston") (or Pkg.add("Gadfly") commands). For documentation and usage examples please refer to the linked repositories.

Upvotes: 11

L.J
L.J

Reputation: 1084

OK I found the solution myself,

Julia uses a web REPL to provide some basic graphics capabilities. Just have to follow the steps here:

https://github.com/JuliaLang/julia#web-repl

Julian Schrittwieser also has a library based on MathGL:

http://www.furidamu.org/blog/2012/02/26/plotting-with-julia/

I am not sure whether it is still under maintenance by the author.

Upvotes: 1

Related Questions