在朱莉娅中使用matplotlib的补丁

时间:2015-05-20 13:44:08

标签: matplotlib julia

使用julia中的计算输出(在IJulia中工作),我想使用matplotlib的补丁模块(通过Steven Johnson的PyCallPyPlot包)绘制一个数字。我已经阅读了stackoverflow上的几个相关帖子,但我似乎无法得到最小的工作示例。有人可以发一个简单的例子吗?说一些绘制矩形或椭圆的东西?

这是一个有效的python示例:

#!/usr/local/bin/python3
import matplotlib.pyplot
import matplotlib.patches

cfig = matplotlib.pyplot.figure()
c = cfig.add_subplot(111)
c.set_aspect("equal")
p = matplotlib.patches.Circle([0.5,0.5],0.40,fc="blue",ec="red",linewidth=5,zorder=0)
c.add_patch(p)

cfig.savefig("circle.pdf",bbox_inches="tight")

我在Julia的同样事情中的尝试在子剧情中停滞

using PyPlot
using PyCall
@pyimport matplotlib.patches as patches

cfig = figure()
c = cfig.add_subplot(111)

哪个收益率:

type Figure has no field add_subplot
while loading In[19], in expression starting on line 4

1 个答案:

答案 0 :(得分:3)

好的,多亏了jverzani的链接,我能够拼凑出一个有效的例子。我对Julia中的语法设置所有选项仍然有点不稳定。

using PyPlot
using PyCall
@pyimport matplotlib.patches as patch

cfig = figure()
ax = cfig[:add_subplot](1,1,1)
ax[:set_aspect]("equal")
c = patch.Circle([0.5,0.5],0.4,fc="blue",ec="red",linewidth=.5,zorder=0)
ax[:add_artist](c)
cfig[:savefig]("circle.png")