recognizing that you intend to handle all of this in a program, the following IJulya ( IJulia / Jupyter with a Julia kernel ...) notebook gives a sense of how plot() results are treated as "figure" objects:
https://cloud.sagemath.com/projects/f8b7156e-2e6b-42c9-a53d-b3ae2355f00e/files/2015-04-25-100946.html good luck, cdm
