Adding a patch in pyplot

I’m translating an example i found on the web.

the part I can’t figure out is this


there is a top level method in PyPlot, but that won’t work, because add_patch is clearly a method as plt.gca() should return the current graphic context.

so then I figured the usual trick might work, i.e.


but that doesn’t work either, because the gca key doesn’t exist.

any ideas on how I might do this ?

thank you !

here’s the code so far - ignore gca[:add_patch]- that doesn’t work

    xlim(0.0, 0.005)
    ylim(0.0, 0.005)
    circle = matplotlib[:patches][:Circle]((0.001, 0.001), radius = 0.001, facecolor="b")

I was looking at an outdated example. I went to the matplotlib docs and was able to create some code that worked !
for reference here’s the page:

using PyPlot

fig, ax = subplots()
xlim(0.0, 0.005)
ylim(0.0, 0.005)
circle1 = matplotlib[:patches][:Circle]((0.001, 0.001), radius = 0.001, facecolor="b")
circle2 = matplotlib[:patches][:Circle]((0.003, 0.003), radius = 0.001, facecolor="r")
p = matplotlib[:collections][:PatchCollection]([circle1, circle2])

just a couple of problems.

the second circle color is still blue. i think this may be a problem with the use of collections. it looks like maybe I need to perform a separate operation to set colors.

also I get the following warning when i run the code:

┌ Warning: The start/next/done iteration protocol is deprecated. Implement `iterate(::PyCall.PyDict{Symbol,PyCall.PyObject,true})`.
│   caller = ip:0x0
└ @ Core :-1

I’m running 0.7, not 1.0, maybe it’s a 0.7 thing ?

Youre correct - the warning is a deprecation warning for moving from 0.6 to 1.0 (that’s what the 0.7 release is for), I’m guessing for PyPlot. From what I can tell, it hasn’t been updated to support 1.0 yet, though there’s a bunch of activity on the front.