plotnine: How to caption?

1k Views Asked by At

I have a plot and I'd like to make the "source: JHU" line into a caption. There are a number of issues some open and others closed regarding this in plotnine's github.

It has been brought to my attention that if I move the axis label to the right and reduce the font size, I can approximate what I want. For the font size, I suppose I can get away with element_text. However, I cannot figure out how to make the axis label appear on the bottom right. Anyone have any idea?

Thanks in advance...

1

There are 1 best solutions below

1
On

This is more of a hack, but within the element_text you can use the ha parameter and pass it the string "left" to make the label be offset to the right, but this only offsets it to the right of the center of the axis. So you can push it further to the right by adding space to the front by using something like plotnine.labs('{:>50}'.format("source: JHU...")) to make the label be any number of characters long (50 here) and aligned right.