-1

Is there other way to make legend's title in bold? Why all the words are joint? enter image description here

Here my code:

    myLegend=plt.legend(bbox_to_anchor=(0., 1.2, 1., .102), prop ={'size':10}, loc=10, ncol=4,
                title=r'$\bf{TOTAL ACCURACY AND PER STAGE - RANDOM FOREST}$')

    myLegend.get_title().set_fontsize('24')
Aizzaac
  • 3,146
  • 8
  • 29
  • 61
  • Possible duplicate of [How to create a draggable legend in matplotlib?](http://stackoverflow.com/questions/2539477/how-to-create-a-draggable-legend-in-matplotlib) – Paul H Sep 14 '16 at 19:10
  • Thanks, I will check the link. Anyway... do you know why all the words are all joint in the legend's title? – Aizzaac Sep 14 '16 at 19:14
  • 1
    I don't know the right words, but it seems you are using latex-rendering and in some latex-subsets, whitespaces are omitted. Usually (but also try my later links) you would use ```TOTAL~ACCURARY``` where the tilde marks a whitespace. If i'm right, you could also check out [this](http://www.emerson.emory.edu/services/latex/latex_119.html) and [this](http://texblog.org/2014/04/09/whitespace-in-math-mode/). – sascha Sep 14 '16 at 19:42
  • Thanks Sascha. I tried it, but it did not work. I used instead: \enspace – Aizzaac Sep 14 '16 at 19:57
  • 1
    you passed the title in a mathtext, which has no spaces. Remove the `$`'s – Paul H Sep 14 '16 at 20:42
  • I removed $\bf{}$ and it worked. – Aizzaac Sep 15 '16 at 12:27

1 Answers1

0

Answer 1:

    myLegend=plt.legend(bbox_to_anchor=(0., 1.2, 1., .102), prop ={'size':10}, loc=10, ncol=4,
                title=r'$\bf{TOTAL\enspace ACCURACY\enspace AND\enspace PER\enspace STAGE\enspace-\enspace RANDOM\enspace FOREST}$')

Answer 2:

    myLegend=plt.legend(bbox_to_anchor=(0., 1.2, 1., .102), prop ={'size':10}, loc=10, ncol=4,
                title=r'TOTAL ACCURACY AND PER STAGE-RANDOM FOREST')

enter image description here

Aizzaac
  • 3,146
  • 8
  • 29
  • 61