From: Azalee Bostroem Date: Fri, 26 Oct 2012 14:28:27 +0000 (-0400) Subject: Updated make_img.py to create both plots in a single figure X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3012253133e07de49b43def6fc4184c4c5f63445;p=swc-testing-nose.git Updated make_img.py to create both plots in a single figure --- diff --git a/4-SoftwareEngineering/make_img.py b/4-SoftwareEngineering/make_img.py index 6eda5d7..eb4e66d 100644 --- a/4-SoftwareEngineering/make_img.py +++ b/4-SoftwareEngineering/make_img.py @@ -1,25 +1,24 @@ import numpy as np import pylab +import pdb + #read in the image img = np.genfromtxt('spec_example.dat') +ax_img = pylab.axes([0.1, 0.1, 0.65, 0.8]) #[left, bottom, width, height] +ax_plot = pylab.axes([0.77, 0.1, 0.13, 0.8]) + + + + #Display the image -pylab.imshow(img, origin = 'lower', interpolation = 'nearest') -pylab.xlim(0, 150) +ax_img.imshow(img, origin = 'lower', interpolation = 'nearest') #Collapse the spectrum along x axis img_collapse = np.sum(img, axis = 1) #create and array to plot against -y = np.arange(np.shape(img_collapse)[0]) - -#Make a different figure -#pylab.figure() -#pylab.plot(img_collapse, y) +y = np.arange(img_collapse.shape[0]) -#--------OR--------- -#Plot on the same figure -#Create a twin y axis -pylab.twiny() #Plot to new axis -pylab.plot(img_collapse, y, 'k', lw = 2) -pylab.xlim(0, 60000) +ax_plot.plot(img_collapse, y, 'k', lw = 2) +ax_plot.set_ylim(ax_img.get_ylim())