Clearing axis cache on Julia REPL

I have this program

using PythonPlot

x = [1, 2]
y = Float64[1.01, 1.02]

fig1 = pyplot.figure(1)
ax1 = fig1.add_subplot(1, 1, 1)
plot(x, y, '.')
pyplot.suptitle(L"title", fontsize=12)
ax1.set_ylabel(L"x \ axis", fontsize=12)
ax1.set_xlabel(L"y \ axis", fontsize=12)

But running various time

include("file.jl")

Axis stack one on top of the other.

You could even try changing the name of an axis and see how it appears over the previous one.

Is there a way to clear axis with the plot?

With PythonPlot, we are just using matplotlib.

So just use pyplot instead of plt to create a new figure.

The figure at line 6 was created with pyplot. No plt was used.

Right, so try passing nothing to pyplot.figure.

Either pyplot.figure() or pyplot.figure(nothing). This will set it to create a new figure everytime.

https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.figure.html

Everytime you say pyplot.figure(1) it tries to reuse the same figure number one.

Can you write me a running example? I can’t figure out how you want to write that

Try this:

using PythonPlot

x = [1, 2]
y = Float64[1.01, 1.02]

fig1 = pyplot.figure()
ax1 = fig1.add_subplot(1, 1, 1)
plot(x, y, '.')
pyplot.suptitle(L"title", fontsize=12)
ax1.set_ylabel(L"x \ axis", fontsize=12)
ax1.set_xlabel(L"y \ axis", fontsize=
1 Like