4

Here is my code

import os,sys
import Image
import matplotlib.pyplot as plt
from matplotlib.pyplot import *
from matplotlib.font_manager import FontProperties

jpgfile = Image.open("t002.jpg")

# Set up the figure and axes.
fig = plt.figure(figsize=(18,10))  # ...or whatever size you want.
ax = fig.add_subplot(111)
ax.legend(fontsize=18)
# Draw things.
plt.imshow(jpgfile)  # Unlike plot and scatter, not a method on ax.
ax.set_xlabel('normalized resistivities')
ax.set_ylabel('normalized velocities')
ax.set_xticks([]); ax.set_yticks([])

# Save and show.
plt.savefig("fig.jpg")
plt.show()

But

/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_axes.py:519: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots

How should I set the labels?

Richard Rublev
  • 7,718
  • 16
  • 77
  • 121

1 Answers1

11

Legend fonts are customized by providing a dict of font property-value pairs to the 'prop' kwarg:

ax.legend(prop=dict(size=18))
farenorth
  • 10,165
  • 2
  • 39
  • 45