how to display julia Gadfly plot in atom editor? - plot

using Gadfly
xvalues = rand(1000);
yvalues = rand(1000);
Gadfly.plot(x=xvalues,y=xvalues,Geom.point,Geom.line)
I am trying make a plot using julia Gadfly package in the atom editor . it does display any plot in the plot panel

This should have been fixed by GiovineItalia/Gadfly.jl/pull/1373 (in Gadfly v1.2). What version of Gadfly do you have?:
julia> ]st Gadfly
If you have an older version, try doing popdisplay(), and redoing the plot.

Related

Cannot plot with Gadfly when running script with `julia -i`

When running julia REPL from the command line and copy-pasting my script, the Gadfly plot command works as expected.
But, when running julia -i scriptname.jl plot no longer works and prints:
julia> DataFrame(CSV.File("file.csv"))
julia> plot(massdf, x=:date, y=:mass, group=:day, color=:day, Geom.line)
Plot(...)
julia>
Is there a setting needed to make it work?
You need to explicitly display the output of plot() in your script (which is done implicitly in a Read-Eval-Print-Loop but not when the whole script is executed, even with -i).
Use display(p::Plot), or draw(backend::Compose.Backend, p::Plot) :
df = DataFrame(CSV.File("file.csv"))
p = plot(df, x=:date, y=:mass, group=:day, color=:day, Geom.line)
display(p)
See also Gadfly Backends.

Using Gadfly interactively in Pluto

I am using Gadfly in Pluto and I am trying to figure out if it is possible to have interactive versions of the plots in Pluto notebooks. If I just use the REPL, Gadfly produces very nice interactive plots that are opened in my web browser:
using Gadfly
plot([sin, cos], 0 , 4)
However, if I use Gadfly in Pluto, the plots that are included in the notebook are not interactive, they are static. This is a simple example of a Pluto notebook:
### A Pluto.jl notebook ###
# v0.12.20
using Markdown
using InteractiveUtils
# ╔═╡ 7bb74118-73d1-11eb-2bd5-c1ef89972288
using Gadfly
# ╔═╡ 9080ac2e-73d1-11eb-18d6-5f85903a7259
plot([sin, cos], 0 , 4)
# ╔═╡ Cell order:
# ╠═7bb74118-73d1-11eb-2bd5-c1ef89972288
# ╠═9080ac2e-73d1-11eb-18d6-5f85903a7259
How can I have interactive versions of the Gadfly plots in Pluto?
Any help is much appreciated!
Following the suggestion in https://github.com/fonsp/Pluto.jl/issues/546#issuecomment-705556778
You can define:
struct HTMLDocument
embedded
end
function Base.show(io::IO, mime::MIME"text/html", doc::HTMLDocument)
println(io, "<html>")
show(io, mime, doc.embedded)
println(io, "</html>")
end
And then do
plot([sin, cos], 0 , 4) |> HTMLDocument
To get the interactive plot in Pluto.
Best,

Can’t display PyPlot in Juno

I have a problem about the plot data on juno using pyplot.
using PyCall
using PyPlot
x = linspace(0,2*pi,1000); y = sin(3*x + 4*cos(2*x))
plot(x, y, color="red", linewidth=2.0, linestyle="--")
After I did "eval all" in Juno, nothing happened.
Is there a solution in solving this problem?
thanks
plotwill only return a vector of PyObjects.
To display the figure interactively in Juno use gcf() (get current figure).

Julia Gadfly error: add_plot_element not found

Using Julia 0.3.10 with Juno as IDE and Gadfly latest one. Tried running a sample code, but got stuck with add_plot_element not defined error message. The last line throws the error. Running on Win8 64bit. I'm sure I'm missing something.
using Gadfly
xs = [0:0.1:pi]
k = layer(x=xs, y=sin(xs))
p = plot(x=xs, y=sin(xs))
add_plot_element(k, Guide.title("Now it has a title"))
First, add_plot_element is modifying, so you need the ! like:
add_plot_element!(k,Guide.title(...))
This function is also not exported from Gadfly, so you would really need to write:
Gadfly.add_plot_element!(k, Guide.title("Now it has a title"))
except add_plot_element! doesn't work on Gadfly layers! It does, however, work on plots. What should work:
Gadfly.add_plot_element!(p, Guide.title("Now it has a title"))
since the layer itself doesn't have Guide.Title elements, but the plot does.

Using "expression" in R rgl axis labels

Do the rgl routines accept the use of "expression" for Greek letters and super/sub script for axis labelling?
Something like
xlab=(expression(paste("Lyman ",alpha,)))
works perfectly well in a normal plot call but just seems to display "(paste("Lyman ",alpha,)" as my axis label in plot3d and decorate3d. If not, how can I add these characters to my 3D scatterplots generated using plot3d?
On my system (OSX 10.7.5, R 3.1.2) I get an alpha as xlab with:
require(rgl)
plot3d(1,1,1,xlab=intToUtf8(0x03B1L) )
And pasting to ordinary text also succeeds:
plot3d(1,1,1, xlab=paste("Lyman ", intToUtf8(0x03B1L) ) )

Resources