How do I place 2 python matplotlib "Figures" inside a parent window?

32 Views Asked by At

I have a python script where one figure is a set of sliders that control the variables for an X/Y parametric plot in a separate window (figure). The slider window and the graph window open seperately on top of each other. How do I place them inside a parent window? I tried subplot() with the figures inside but the script hangs with no error message. Disconnected windows

#! /usr/bin/python3

# THIS IS A TRUNCATED SCRIPT FOR INSTRUCTIVE PURPOSES

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button
from datetime import datetime
import math 

plt.rcParams['figure.facecolor'] = 'darkgreen'
plt.rcParams["figure.figsize"] = [8.0, 8.0]
plt.rcParams["figure.autolayout"] = True

def save(event):
    fig1.savefig("saved_plot", format="svg")

# THE FIGURES
fig1, ax = plt.subplots()
plt.get_current_fig_manager().set_window_title(" Figure")

fig2, aQ = plt.subplots()
plt.get_current_fig_manager().set_window_title(" Settings")

# Make a horizontal slider to control Radius-1.
axRAD1 = plt.axes([0.25, 0.90, 0.65, 0.03])
R1_slider = Slider(
    ax=axRAD1,
    label='Radius 1',
    valmin= 0.0,
    valmax= +10.0,
    valinit=1,
    orientation="horizontal")
    
saveax = plt.axes([0.1, 0.05, 0.1, 0.04])
button2 = Button(saveax, 'Save', color="lightgray", hovercolor='red')
button2.on_clicked(save)

plt.show()
0

There are 0 best solutions below