biotite.set_font_size_in_coord

biotite.set_font_size_in_coord(text, width=None, height=None, mode='unlocked')[source]

Specifiy the font size of an existing Text object in coordinates of the object’s reference coordiante system.

Instead of having the font size fixed in ‘pt’, the size of the text scales to the specied width/height and adapts to changes in the plot’s width/height. The scaling can be proportional or non-proportional, depending the mode.

Parameters
textText:

The matplotlib Text to be scaled.

width, heightfloat, optional

The new width/height of text in its reference coordinate system. At least one value must be supplied.

mode{‘proportional’, ‘unlocked’, ‘maximum’, ‘minimum’}, optional

The scaling mode:

  • proportional - The width and height are scaled by the same extent. Either width or height must be set for this mode.

  • unlocked - The width and the height are scaled by different extents, changing the aspect ratio. Both width and height must be set for this mode.

  • maximum - The width and the height are scaled by the same extent, so that they are at maximum as large as the supplied width/height. Both width and height must be set for this mode.

  • minimum - The width and the height are scaled by the same extent, so that they are at minimum as large as the supplied width/height. Both width and height must be set for this mode.

Notes

This function uses the get_window_extent() method of the Text object. According to experience, this function does not give the the exact visual boundaries of the text. Consequently, the scaled text might be slightly smaller or larger than the specified width/height. This behavior is not equal for all initial font sizes (in ‘pt’), the boundaries for an initial size of 1 ‘pt’ seem to be most exact.