Last active
December 30, 2015 08:39
-
-
Save cwidmer/7804306 to your computer and use it in GitHub Desktop.
snippet to create matplotlib plot with title, grid and externally located legend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylab | |
data1 = [1,2,3,4] | |
data2 = [2,3,4,5] | |
pylab.plot(data1, "-o", label="meh") | |
pylab.plot(data2, "-o", label="arr") | |
pylab.title("example") | |
pylab.grid(True) | |
ax = pylab.axes() | |
box = ax.get_position() | |
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) | |
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) | |
pylab.savefig("test.pdf") | |
#pylab.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment