PyLab - change text color and fill color of text field background

I use PyLab to create some graphs in Python. I want to create a text box with color purple with black text, but the text cannot be black.

text(x, y, 'Summary', backgroundcolor = 'm', color = 'k')

This gives me a magenta background and then text that is almost the same pink. Any ideas what I'm doing wrong?

Many thanks!

+3
source share
1 answer

it doesn't seem like you are doing something wrong:

In [23]: pylab.text(0.25, 0.5, 'test', backgroundcolor='m', color='r')
In [24]: pylab.text(0.5, 0.5, 'test', backgroundcolor='m', color='k')
In [25]: pylab.text(0.75, 0.5, 'test', backgroundcolor='m', color='b')

alt text http://student.physics.ucdavis.edu/~rjames/test.png

perhaps somewhere else in your code (or the matplotlib installation) the matching of strings with colors was distorted?

+4
source

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


All Articles