Creating border around inset graph

Hi,

I am trying to form a border around one of the inset graphs i have created in plotly, but I am wondering what the best way to do this would be? I wish to have the entire inset graph (picture attached here) to be bordered with a black line (which I will then connect with line segments to the black box in the upper right corner of the graph). I have tried to do this with shapes() command and form a rectangle around the plot but I am not having much luck. I am able to form the lines, but its quite ugly having to match the secondary xaxis/yaxis dimensions and I am not sure how to make the border also encapsulate the axis titles as well in a clean manner

Is there a more straightforwards way to approach this?