1

On pyplot - I can't figure out (pun not intended) how to make the text and the box of the legend bold (well, the text bold and the linewidth of the box wider). That's what I have so far.

import pylab as plt
fig = plt.figure()
ax = fig.add_subplot(111)
...
ax.bar(...)
...
ax.legend(loc='best',prop={'size':35})
mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
nerez
  • 437
  • 4
  • 18
  • 1
    You can insert tex/latex, see http://stackoverflow.com/questions/8376335/styling-part-of-label-in-legend-in-matplotlib – Scott Apr 20 '15 at 16:37
  • Thanks Scott, I ended up using FontProperties from here (it has size and weight) http://stackoverflow.com/questions/4700614/how-to-put-the-legend-out-of-the-plot – nerez Apr 20 '15 at 16:39
  • 1
    Now you know how to do it two ways :) – Scott Apr 20 '15 at 16:41

1 Answers1

0

The legend demo in the matplotlib gallery subtly shows both of these -- note that the original reset the font size and got access to the frame Rectangle (to change the color). Add one next-to-last line:

legend.get_frame().set_linewidth(3.0)

and the rectangle frame is heavier:

enter image description here

cphlewis
  • 15,759
  • 4
  • 46
  • 55