Home > Software engineering >  How to round connection for Matplotlib axis spines
How to round connection for Matplotlib axis spines

Time:11-21

This is a fairly simple question. I am working on creating a Matplotlib figure that has several inset axes.

I have removed the tick marks so that the inset spines of each of the inset axes meet at a 90 degree angle. However, when you add a legend to this figure, it adds a legend object that has slightly rounded spine connections for each "edge" of the legend object.

Is there an easy way to get a similar effect for the spines of an inset axis or axis more generally?

My code:

fig, e = plt.subplots(figsize=(10, 5))
    
a = e.inset_axes([.1, .1, .1, .2])
b = e.inset_axes([.3, .1, .1, .2])

for ax in [a, b]:
    
    ax.set_yticks([])
    ax.set_xticks([])

Current output:

enter image description here

Desired output:

enter image description here

CodePudding user response:

An idea is to hide the spines, and draw a inset axis with rounded corners

  • Related