seaborn.objects.Text#

class seaborn.objects.Text(artist_kws=<factory>, text=<''>, color=<'k'>, alpha=<1>, fontsize=<rc:font.size>, halign=<'center'>, valign=<'center_baseline'>, offset=<4>)#

A textual mark to annotate or represent data values.

This mark defines the following properties:

text, color, alpha, fontsize, halign, valign, offset

Examples

Add text at x/y locations on the plot:

(
    so.Plot(glue, x="SST-2", y="MRPC", text="Model")
    .add(so.Text())
)
../_images/objects.Text_1_0.png

Add bar annotations, horizontally-aligned with halign:

(
    so.Plot(glue, x="Average", y="Model", text="Average")
    .add(so.Bar())
    .add(so.Text(color="w", halign="right"))
)
../_images/objects.Text_3_0.png

Fine-tune the alignment using offset:

(
    so.Plot(glue, x="Average", y="Model", text="Average")
    .add(so.Bar())
    .add(so.Text(color="w", halign="right", offset=6))
)
../_images/objects.Text_5_0.png

Add text above dots, mapping the text color with a third variable:

(
    so.Plot(glue, x="SST-2", y="MRPC", color="Encoder", text="Model")
    .add(so.Dot())
    .add(so.Text(valign="bottom"))

)
../_images/objects.Text_7_0.png

Map the text alignment for better use of space:

(
    so.Plot(glue, x="RTE", y="MRPC", color="Encoder", text="Model")
    .add(so.Dot())
    .add(so.Text(), halign="Encoder")
    .scale(halign={"LSTM": "left", "Transformer": "right"})
)
../_images/objects.Text_9_0.png

Use additional matplotlib parameters to control the appearance of the text:

(
    so.Plot(glue, x="RTE", y="MRPC", color="Encoder", text="Model")
    .add(so.Dot())
    .add(so.Text({"fontweight": "bold"}), halign="Encoder")
    .scale(halign={"LSTM": "left", "Transformer": "right"})
)
../_images/objects.Text_11_0.png