0

I am plotting a specific figure using the following program:

alpha, beta = 0.5, 0.5
fig, ax = plt.subplots(1, 1, figsize = (6,3))
ax.set_title(r"Predicted $x$ with Bayes Factor w.r.t. $\beta(1,1)$:" + "\n" 
             + "> 3 (green) or < 3 (blue)" + "\n" 
             + r"when prior = $\beta$" + f"({alpha}, {beta}) " 
             + f"[n = {n}] " + "-NO DATA-", 
             fontsize = '15')
plt.show()

Is there a way to modify the instructions given to ax.set_title in order to have the text >3 (green) displayed in green color and the text >3 (blue) displayed in blue color, inside the whole title?

I tried to play with r"\textcolor{green}{> 3 (green)}" (as an example) but that turned out to be useless...

Should I need to split the title in several parts with different specifications in each part? But how to do that, if it is the case?

Or is there a nice pythonic way to do the job?

Any advice highly appreciated.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Andrew
  • 926
  • 2
  • 17
  • 24
  • 2
    No. The title is all one color. You can add your own text to the graph, however. – Tim Roberts May 10 '23 at 22:47
  • See https://stackoverflow.com/questions/9169052 and https://stackoverflow.com/questions/36264305 – JohanC May 11 '23 at 05:26
  • Thanks for the links, but really not easy to implement. Following `Tim Roberts` suggestion, I rather vote to use `ax.annotate()` and specify `color = ***` inside the annotation... – Andrew May 11 '23 at 14:54

0 Answers0