FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Doc]: alpha setting for annotation `TextArea` · Issue #24390 · matplotlib/matplotlib · GitHub

Repository navigation

[Doc]: alpha setting for annotation TextArea #24390

Closed

Description

Bug summary

I've been adding annotations following the excellent examples at AnnotationBbox demo, but I'd like to make the text box transparent. From the TextArea docs it looks like my_text_area.set(alpha=x) should work, but it doesn't seem to have any effect.

Perhaps there is another way to set this that I have missed?

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.offsetbox import TextArea, AnnotationBbox

import numpy as np

rng = np.random.default_rng()

data = rng.normal(size=30)

plt.rcdefaults()

_ , ax = plt.subplots()
ax.hist(data)

offsetbox = TextArea('Look over there!')
offsetbox.set(alpha=0.3)

ab = AnnotationBbox(offsetbox, (0.8, 0.8),
            xybox=(0, 1),
            xycoords='axes fraction',
            boxcoords='data',
            arrowprops=dict(arrowstyle="->"))

ax.add_artist(ab)

plt.show()

Actual outcome

Expected outcome

The text box should be transparent.

Additional information

I tried a few versions back to 3.3, but the result was the same.

Operating system

RHEL7

Matplotlib Version

3.6.2

Matplotlib Backend

QtAgg

Python version

3.8.13

Jupyter version

N/A

Installation

conda

Activity

  1. QuLogic commented on Nov 8, 2022

    Member

    You'll need to pass bboxprops=dict(alpha=0.3) to the AnnotationBbox. The TextArea does not draw any background.

  2. rcomer commented on Nov 8, 2022

    MemberAuthor

    Thanks @QuLogic, that did the trick. So I guess there isn't actually a bug here. Possibly a documentation issue? Or should we close this?

  3. oscargus commented on Nov 8, 2022

    Member

    Seems like there arguments are not documented: bboxprops=None, arrowprops=None, fontsize=None so that can for sure be a good idea. Probably with a comment about how to make it transparent (which seems like a common enough use case).

  4. changed the title [-][Bug]: alpha setting for annotation `TextArea`[/-] [+][Doc]: alpha setting for annotation `TextArea`[/+] on Nov 8, 2022
  5. added this to the v3.6.3 milestone on Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL