Pyplot: subplot_mosaic

Today’s post is gon­na be the start of a new series diving into the details of crea­ting nice[r] plots with Python. As I alre­a­dy men­tio­ned in a simi­lar post last year, this coll­ec­tion is also a hel­pful remin­der for me when­ever I look up the same things again and again.

One par­ti­cu­lar thing which always dri­ves me cra­zy is adjus­ting panels in some­what more com­pli­ca­ted plots using Python’s sub­plots. Howe­ver, recent­ly I found an extre­me­ly useful func­tion sim­pli­fy­ing this a lot: pyplot.subplot_mosaic ! This func­tion allows us to crea­te real­ly exo­tic con­fi­gu­ra­ti­ons of panels just by sket­ching what we want direct­ly in Python. What else could we wish for!?

Ins­tead of going through a step-by-step gui­de essen­ti­al­ly repea­ting the docu­men­ta­ti­on, I had ano­ther idea: Why not recrea­te a plot I published in a paper some time ago – and may­be polish it a bit fur­ther along the way. Our start­ing point is the plot on the right. To be honest, this is by far not the nicest plot I ever crea­ted and it defi­ni­te­ly can be impro­ved a lot (as I did for my PhD thesis…).

Howe­ver, our focus shall be on using subplot_mosaic and only impro­ving some things for a slight­ly sim­pli­fied ver­si­on of this figu­re. So let’s get started!

So let’s compa­re the final ver­si­on to the initi­al one:

Yes, I know, the new ver­si­on is lack­ing some iden­ti­fy­ing (a‑c)’s, but for a solu­ti­on exclu­si­ve­ly using Python wit­hout any poli­shing in Inkscape I’m pret­ty hap­py with the result.

What are your secrets for crea­ting nice, con­sis­tent plots? Any spe­cial func­tions you use?

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.