Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Thu Apr 12 11:16:03 2012
- Using the current stable version of pythonxy on Windows 7 32bit
- Author: Jonathan
- Notice how the figure box is not placed correctly, effectively missing the
- legend entirely
- """
- import matplotlib.pyplot as plt
- import numpy as np
- x = np.arange(-2*np.pi, 2*np.pi, 0.1)
- fig = plt.figure(1)
- ax = fig.add_subplot(111)
- ax.plot(x, np.sin(x), label='Sine')
- ax.plot(x, np.cos(x), label='Cosine')
- ax.plot(x, np.arctan(x), label='Inverse tan')
- handles, labels = ax.get_legend_handles_labels()
- lgd = ax.legend(handles, labels, loc='upper center', bbox_to_anchor=(0.5,-0.1))
- ax.grid('on')
- fig.savefig('samplefigure', bbox_extra_artists=(lgd,), bbox_inches='tight')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement