Matplotlib text transformation

I was wondering if it is possible to change the transparency of the text in Matplotlib. set_alphadoes not work, and in the documentation I could not find anything suitable. Are there any workarounds?

I want to associate it with pick_event.

EDIT: I really tried to change the transparency of the legend text. Although I tried to solve the problem with help set_alpha, I observed that I was trying to change the transparency of the list, and therefore I could not succeed. To summarize, as can be seen from the answers, transparency can be changed usingset_alpha

+4
source share
2 answers

annotate, .

:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

ax.annotate("TESTING", xy=(.5, .5), xytext=(.5, .5),
           )

plt.show()

enter image description here

:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

text = ax.annotate("TESTING", xy=(.5, .5), xytext=(.5, .5),
                  )

text.set_alpha(.4)

plt.show()

enter image description here

+4

, :

ax.plot([1,2,3], [4,5,6], label='Null')
leg = ax.legend()

# print dir(leg) # inspection
for _txt in leg.texts:
    _txt.set_alpha(0.3)

. , mpl, . texts .

+2

Source: https://habr.com/ru/post/1543436/


All Articles