Weave with PyPlot.jl

Hello,

I am trying to use Weave.jl with PyPlot for plotting (on v0.7), but I am not getting any plot in the PDF or HTML document. Did someone was successful to use Weave with PyPlot? (For the moment, I am just trying to make the example julia_sample.mdw work, from Weave)

Thank you.

Can you post an MWE so that people can try out what youā€™re doing and see whether it might be due to e.g. some issue with your PyPlot installation?

1 Like

So I finally fixed my problem, thank you. I tried to to follow the example in the Weave package but it was not working. My original code looked as the following ():

## Capturing figures
The figures and code can be included in the output.

<<term=false;echo=false>>=
using PyPlot
PyPlot.close()
x = [1:1:50;];
y = 10*rand(50);
fig = figure("pyplot_barplot",figsize=(5,5))
b = bar(x,y,color="#0f87bf",align="center",alpha=0.9)
axis("tight")
title("Vertical Bar Plot")
grid(true)
xlabel("X")
ylabel("Y")
@

And when I was using weave
weave(joinpath(dirname(pathof(Weave)), "../examples", "julia_example.mdw"),out_path=:pwd, doctype="md2html")
The plot was not included in the html (same thing with ā€˜md2pdfā€™).
I finally add display(fig); and it finally worked.

## Capturing figures
The figures and code can be included in the output.

<<term=false;echo=false>>=
using PyPlot
PyPlot.close()
x = [1:1:50;];
y = 10*rand(50);
fig = figure("pyplot_barplot",figsize=(5,5))
b = bar(x,y,color="#0f87bf",align="center",alpha=0.9)
axis("tight")
title("Vertical Bar Plot")
grid(true)
xlabel("X")
ylabel("Y")
display(fig);
@

Iā€™m a new comer here. I ran the julia_example.mdw in julia-1.0.1 with the same problem with ā€œERROR: UndefVarError: linspace not definedā€.

But I had just read the earlier posting " UndefVarError: linspace not defined.

We need to add Weave.jl to their list of deprecated ā€˜linspaceā€™ usages in the julia space.

:slight_smile:

Gary

HI Gary,

My personal advice is to use julia-v0.7 for the moment. Some useful packages are not yet up to date with Julia-v1, the advantage of julia-v0.7 is it will output a warning message instead of error message and it will indicate what is deprecated and what is now recommended.
I think that the examples in Weave.jl are outdated. Therefore, it is really time consuming to figure it out how it should work.

1 Like