code: public void remove(Plot p) {
          shapes.remove(p);
  
          JComponent[] tb = p.getToolBar();
          if (tb != null) {
              for (JComponent comp : tb) {
                  toolbar.remove(comp);
              }
          }
  
          repaint();
      }
docs: Remove a graphical shape from the canvas.