proplot icon indicating copy to clipboard operation
proplot copied to clipboard

Manually specify `title` and `abc` coordinate positions

Open scottstanie opened this issue 4 years ago • 6 comments

Description

Hi, is it possible to make the abc labels slightly offset to the left from the axis? This would probably be a negative position.

image

I was hoping to have the (b) moved slightly left so that I can center the title without the two texts crashing into each other.

I tried the following after having all of my "imshow" and other formatting code run:

ax = axes[2]
aobj = ax._title_dict['abc']
print(aobj.get_position()) # prints (0, 1.0)

# no effect
aobj.set_x(-.25)

# no effect
abc = ax.get_children()[1]
abc.set_position((-.25, 1.0))

I couldn't figure out what was running to overwrite these positions, but I assume it's something internal to proplot to make the layout nice and orderly.

Proplot version

>>> import matplotlib; print(matplotlib.__version__); import proplot; print(proplot.version)
3.3.0
0.9.1

scottstanie avatar Sep 27 '21 22:09 scottstanie

This is definitely a fair request. I can support more label position customization by:

  1. Not auto-adjusting the x-location for "outer" labels (which would fix your example).
  2. Allow passing 2-tuples to abcloc and titleloc to specify the coordinate position of an "inner" label.

For now, in your example, you should be able to use ax.format(titleloc='center', abcloc='center') and the a-b-c label will be automatically offset away from the title (i.e., same effect as giving a "left" label a negative x position). You can increase/decrease this offset by changing pplt.rc['abc.titlepad'] or using ax.format(abctitlepad=padding).

lukelbd avatar Sep 29 '21 00:09 lukelbd

Thanks for the suggestion, though when I have seems to move the title off to the right before it moves the (b) off to the left:

ax.format(title=f"$\sigma_n$=12", abcloc='center', titleloc='center', abctitlepad=12)
image

I tried a few other combos of "left" (makes it worse)

image

But it gets closer with "right": image

scottstanie avatar Sep 29 '21 00:09 scottstanie

Sorry for the delay. I see now, you want a "centered" title but want the a-b-c label offset toward the left (rather than centering the entire a-b-c label/title ensemble as in your first example).

Will look into this when I get the chance, but for now your best bet is probably this "hacky" solution: 1) set both titleloc='center' and abcloc='center' and play with abctitlepad, as you've done above, then 2) append spaces to the right of the title to prevent the title from getting pushed too far to the right (e.g. title=r'$\sigma_n = 12$' + 5 * ' ').

lukelbd avatar Oct 05 '21 05:10 lukelbd

Alright I'll give it a shot! No worries on quickly implementing this, seems like it might be a rather unique request

On Tue, Oct 5, 2021, 12:42 AM Luke Davis @.***> wrote:

Sorry for the delay. I see now, you want a "centered" title but want the a-b-c label offset toward the left (rather than centering the entire a-b-c label/title ensemble as in your first example).

Will look into this when I get the chance, but for now your best bet is this "hacky" solution: 1) set both titleloc='center' and abcloc='center' and play with abctitlepad, as you've done above, then 2) append spaces to the right of the title to prevent the label from getting pushed too far to the right (e.g. title=r'$\sigma_n = 12$' + 5 * ' ').

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lukelbd/proplot/issues/288#issuecomment-934084751, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB7ILWABBGUXKCYDIUK3ZSDUFKF5FANCNFSM5E3SUSNQ .

scottstanie avatar Oct 05 '21 13:10 scottstanie

No worries on quickly implementing this, seems like it might be a rather unique request

Thanks! I think I'll keep this as an open issue though for the specific feature: specifying titleloc and abcloc with an (x, y) coordinate position rather than preset position.

lukelbd avatar Oct 18 '21 22:10 lukelbd

I also have similar request. I use ax.text(...) "crudely" solved it.

L1angY avatar Jul 08 '22 15:07 L1angY