在朱莉娅中使用matplotlib的补丁

使用julia中计算的输出(在IJulia中工作),我想使用matplotlib的补丁模块(通过Steven Johnson的PyCall和PyPlot包)绘制一个数字.我已经阅读了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

最佳答案 好的,多亏了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")
点赞