# Weave with PyPlot.jl

**URL:** <https://discourse.julialang.org/t/weave-with-pyplot-jl/15859>\
**Category:** New to Julia\
**Created:** [October 4, 2018, 3:06am UTC](https://discourse.julialang.org/t/weave-with-pyplot-jl/15859 "2018-10-04T03:06:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Errazuriz](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@Errazuriz](https://discourse.julialang.org/u/Errazuriz)\
**Post date:** [October 4, 2018, 3:06am UTC](https://discourse.julialang.org/t/weave-with-pyplot-jl/15859/1 "2018-10-04T03:06:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 4, 2018, 7:39am UTC](https://discourse.julialang.org/t/weave-with-pyplot-jl/15859/2 "2018-10-04T07:39:17Z")

</div>

Can you post an [MWE](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757) 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?

---

<div class="post-metadata">

**Author:** ![Errazuriz](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@Errazuriz](https://discourse.julialang.org/u/Errazuriz)\
**Post date:** [October 6, 2018, 7:40pm UTC](https://discourse.julialang.org/t/weave-with-pyplot-jl/15859/3 "2018-10-06T19:40:22Z")

</div>

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 ():

```julia
## 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.

```julia
## 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);
@

```

---

<div class="post-metadata">

**Author:** ![proudindiv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/proudindiv/32/5000_2.png) [@proudindiv](https://discourse.julialang.org/u/proudindiv)\
**Post date:** [October 7, 2018, 12:14am UTC](https://discourse.julialang.org/t/weave-with-pyplot-jl/15859/4 "2018-10-07T00:14:32Z")

</div>

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](https://discourse.julialang.org/t/undefvarerror-linspace-not-defined/13269).

We need to add Weave.jl to their list of deprecated ‘linspace’ usages in the julia space.

🙂

Gary

---

<div class="post-metadata">

**Author:** ![Errazuriz](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@Errazuriz](https://discourse.julialang.org/u/Errazuriz)\
**Post date:** [October 12, 2018, 6:50pm UTC](https://discourse.julialang.org/t/weave-with-pyplot-jl/15859/5 "2018-10-12T18:50:43Z")

</div>

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.
