Is there a way in matplotlib to partially specify the color of a string?
Example:
plt.ylabel("Today is cloudy.")
How can I show "today" as red, "is" as green and "cloudy." as blue?
Thanks.
Is there a way in matplotlib to partially specify the color of a string?
Example:
plt.ylabel("Today is cloudy.")
How can I show "today" as red, "is" as green and "cloudy." as blue?
Thanks.
I only know how to do this non-interactively, and even then only with the 'PS' backend.
To do this, I would use Latex to format the text. Then I would include the 'color' package, and set your colors as you wish.
Here is an example of doing this:
This results in (converted from ps to png using ImageMagick, so I could post it here):
Extending Yann's answer, LaTeX coloring now also works with PDF export:
Note that this python script sometimes fails with
Undefined control sequence
errors in the first attempt. Running it again is then successful.here's the interactive version (same one I posted to the list)