Plot not defined with Julia - plot

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?
Thanks

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.

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);

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.

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.

Related

Fortran plotting without Gnuplot

I am new to Fortran and am trying to learn how to do simple plots. I already have a program that creates a file of the values that I'm looking to test out in a simple plotting exercise, but every example I've seen so far uses gnuplot. As the computer I'm using is not a personal computer, installing or downloading gnuplot is not really the easiest option at first glance.
Would it be correct to assume that without gnuplot, plotting using Fortran 90 is very difficult?
Fortran is a general purpose programming language. It is designed to work on any type of computer, even those without any screen or operating system (with some new possibilities to ineract with an OS if it is present).
All such languages, like Fortran, C or C++ cannot directly do any graphical output or plotting. They require external libraries which are written in a system-specific way to interact with the graphical interface. There are such libraries available for Fortran, but using them is not trivial. It is much (MUCH!) harder than installing gnuplot, if you already know how to use gnuplot.
I will not recommend any such libraries as it is off-topic here.
You can use gtk-fortran. It is a GTK / Fortran binding and it offers also an interface to PLplot:
https://github.com/vmagnin/gtk-fortran/wiki
But you need a Fortran 2003 compliant compiler (it is the case of all recent compilers).
Plotting with Fortran is generally not easy because you need to install such libraries and need to learn their functioning.

Pareto Frontier generation for multi-objective prob. using openMDAO 1.x?

I am new to the OpenMDAO framework and currently using the 1.5.0 version. I'm interested in generating a Pareto front for Zitzler–Deb–Thiele's functions using the same.
I found a solution for the legacy version here which uses 'pareto_filter' but was unable to locate the same in the new version.
So, how do I set up a multi-objective problem to generate pareto front in 1.x version?
Thanks to all.
You should be able to us NSGA2 from pyopt-sparse directly in OpenMDAO. You just install the pyopt-sparse package and OpenMDAO has a driver already built in that will let you use it. Then you pick NSGA2 as your optimizer.
The only issue is that, if you look at the source, that driver is currently labeled as single-objective. So you should change that line to True, so that you can specify multiple objectives.
We haven't tested NSGA2 via the pyopt-sparse. So it might take a little bit of hacking around to get it to work. If you'd prefer to us the regular pyopt package, you should be able to start with our current pyopt-sparse wrapper and make some small changes to get it to work.

rasterGrob function not found in search

I've written a package in which the following is in the imports:
Rcpp (>= 0.11.0),ggplot2,grid,gridExtra,png,methods,ape,Biostrings
I have read this artcle about how R searches: how R searches, and I figured basically unless there's a very good reason not to - it's is safer to import packages that mine depends on, and not to put them in the dependencies.
However I'm seeing the error whe I use my package:
could not find function "rasterGrob"
My suspicion is that ggplot Depends on Grid, so I have to make my package Depend on grid too, so as the grid is attached and so 'package:grid' will be seen when executing search().
A). Is my understanding correct? and B). So do I simply have to also Depend on Grid, or is it a better idea to Depend on ggplot2 also?
Thanks,
Ben.

Using Protovis with R

As question, I have satisfied with what R and ggplot2 can do for static graph, but what about interactive graphs? How combine R and Protovis to make the graphs?
There is somethings called rwebvis but seems it is no longer active.
Any suggestion? Thanks.
Well, first you need a web server. Ooh, R has one of those now. Then you need some way of generating output on the web from R code - ooh, R has one of those too:
http://jeffreybreen.wordpress.com/2011/04/25/4-lines-of-r-to-get-you-started-using-the-rook-web-server-interface/
So you can then write R server pages that return JSON-encoded data that you can feed to Protovis - or if you want to get right up to date, to D3, which is Protovis++ and made of win.
Iplots is a fairly useful package that allows interactive graphing ( by this I mean selection linking between graphs, color linking, etc). It has some limitations and is not really made for producing plots as much as exploring data trends.
Acinonyx also was recently updated which is supposed to be an updated version of iplots, but from what I can tell it still has some work to do.
Not familiar with protovis or rwebvis.
There is a package from google called googlevis that enables some interactivity. This produces plots that are embeddable online. If you like protovis, the same author has another library called D3.
For running R on a webserver, I have been experimenting with RApache, which enables you to link your R installation to an apache server.
If the interactivity does not to be online, RStudio have a package called manipulate which may also be of interest.

R bindings for Mapnik?

I frequently find myself doing some analysis in R and then wanting to make a quick map. The standard plot() function does a reasonable job of quick, but I quickly find that I need to go to ggplot2 when I want to make something that looks nice or has more complex symbology requirements. Ggplot2 is great, but is sometimes cumbersome to convert a SpatialPolygonsDataFrame into the format required by Ggplot2. Ggplot2 can also be a tad slow when dealing with large maps that require specific projections.
It seems like I should be able to use Mapnik to plot spatial objects directly from R, but after exhausting my Google-fu, I cannot find any evidence of bindings. Rather than assume that such a thing doesn't exist, I thought I'd check here to see if anyone knows of an R - Mapnik binding.
The Mapnik FAQ explicitly mentions Python bindings -- as does the wiki -- with no mention of R, so I think you are correct that no (Mapnik-sponsored, at least) R bindings currently exist for Mapnik.
You might get a more satisfying (or at least more detailed) answer by asking on the Mapnik users list. They will know for certain if any projects exist to make R bindings for Mapnik, and if not, your interest may incite someone to investigate the possibility of generating bindings for R.
I would write the SpatialWotsitDataFrames to Shapefiles and then launch a Python Mapnik script. You could even use R to generate the Python script (package 'brew' is handy for making files from templates and inserting values form R).

Resources