def _plot_default(self): data = self.data < self.limit pd = self.pd = ArrayPlotData(imagedata=data,orig=self.data) plot1 = Plot(pd, default_origin='top left') plot2 = Plot(pd, default_origin='top left') img_plot1 = plot1.img_plot("imagedata",colormap=gray,padding=0)[0] img_plot2 = plot2.img_plot("orig",colormap=gray,padding=0)[0] container = HPlotContainer(plot1,plot2) container.spacing=0 plot1.padding_right=0 plot2.padding_left=0 plot2.y_axis.orientation= 'right' return container
def __init__(self): # Create the data and the PlotData object x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x=x, y=y) # Create the scatter plot scatter = Plot(plotdata) scatter.plot(("x", "y"), type="scatter", color="blue") # Create the line plot line = Plot(plotdata) line.plot(("x", "y"), type="line", color="blue") # Create a horizontal container and put the two plots inside it container = HPlotContainer(scatter, line) container.spacing = 0 scatter.padding_right = 0 line.padding_left = 0 line.y_axis.orientation = "right" self.plot = container
def _plot_default(self): # Create the data and the PlotData object x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) # Create the scatter plot scatter = Plot(plotdata) scatter.plot(("x", "y"), type="scatter", color="blue") # Create the line plot line = Plot(plotdata) line.plot(("x", "y"), type="line", color="blue") # Create a horizontal container and put the two plots inside it container = HPlotContainer(scatter, line) container.spacing = 0 scatter.padding_right = 0 line.padding_left = 0 line.y_axis.orientation = "right" return container
def _plot_default(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x=x, y=y) scatter = Plot(plotdata) scatter.plot(("x", "y"), type="scatter", color="blue") line = Plot(plotdata) line.plot(("x", "y"), type="line", color="blue") container = HPlotContainer(scatter, line) container.spacing = 0 scatter.padding_right = 0 line.padding_left = 0 line.y_axis_orientation = "right" return container
def __init__(self): super(ContainerExample, self).__init__() x = linspace(-14, 14, 100) y = sin(x) * x ** 3 plotdata = ArrayPlotData(x=x, y=y) scatter = Plot(plotdata) scatter.plot(("x", "y"), type="scatter", color="blue") line = Plot(plotdata) line.plot(("x", "y"), type="line", color="blue") container = HPlotContainer(scatter, line) #Making the plots touch in the middle container.spacing = 0 scatter.padding_right = 0 line.padding_left = 0 line.y_axis.orientation = "right" self.plot = container
def create_SourcePlot(self): plotvals = self.CalcSourcePlotVals(sel = self.RayFile, xi = 0, yi = 0, wave_ref = self.wave_ref, vmax = float(FileLoadWindow.VMax_Min), zrange=[float(FileLoadWindow.ZRangeMin), float(FileLoadWindow.ZRangeMax)]) #plotvals = self.CalcSourcePlotVals(sel = self.RayFile, xi = 0, yi = 0, wave_ref = self.wave_ref, zrange=[0.2,3.0]) #unpacks values from CalcSourcePlotVals vaxis = plotvals['vaxis'] height = plotvals['height'] chiCT = plotvals['chiCT'] tauCT = plotvals['tauCT'] tau = plotvals['tau'] chi = plotvals['chi'] vz = plotvals['vz'] T = plotvals['T'] Sline = plotvals['Sline'] tau_one = plotvals['tau_one'] bint = plotvals['bint'] wave = plotvals['wave'] vrange = plotvals['vrange'] zrange = plotvals['zrange'] S = plotvals['S'] velocityzero = 299792.45 * (self.Wavelength - self.wave_ref)/self.wave_ref vaxispoints = 100 heightaxispoints = 400 self.new_vaxis = N.linspace(vrange[0], vrange[1], vaxispoints) self.new_height = N.linspace(zrange[0], zrange[1], heightaxispoints) VelocityZeroXPoints = [velocityzero, velocityzero] VelocityZeroYPoints = [self.new_height[0], self.new_height[-1]] #----------------------Create Chi/Tau Plot------------------------------- new_chiCT = lineformInterpolate2D(vaxis, height, chiCT, self.new_vaxis , self.new_height) new_tauCT = lineformInterpolate2D(vaxis, height, tauCT, self.new_vaxis , self.new_height) self._image_indexCT = GridDataSource(xdata = self.new_vaxis, ydata = self.new_height[1:]) index_mapperCT = GridMapper(range = DataRange2D(self._image_indexCT)) self._image_valueCT = ImageData(data = (new_chiCT[:,1:]/new_tauCT[:,1:]), value_depth = 1) color_mapperCT = jet(DataRange1D(self._image_valueCT)) self.ChiTauPlotData = ArrayPlotData(imagedata = (new_chiCT[:,1:]/new_tauCT[:,1:]), index = vaxis, TauOne= tau_one, Velocity = vz, Height = height, VelocityZeroXPoints = VelocityZeroXPoints, VelocityZeroYPoints = VelocityZeroYPoints) self.ChiTauPlot = Plot(self.ChiTauPlotData) self.ChiTauPlot.img_plot1 = self.ChiTauPlot.img_plot("imagedata", colormap = color_mapperCT, xbounds = (self.new_vaxis[0], self.new_vaxis[-1]), ybounds = (self.new_height[0], self.new_height[-1]))[0] self.ChiTauPlot.overlays.append(ZoomTool(self.ChiTauPlot.img_plot1)) self.ChiTauPlot.tools.append(PanTool(self.ChiTauPlot.img_plot1, drag_button="right")) self.ChiTauPlot.TauOnePlot = self.ChiTauPlot.plot(("index","TauOne"), type = "line", color = "red", resizeable = True) self.ChiTauPlot.VelocityPlot = self.ChiTauPlot.plot(("Velocity","Height"), type = "line", color = "green", resizeable = True) self.ChiTauPlot.VelocityZeroPlot = self.ChiTauPlot.plot(("VelocityZeroXPoints","VelocityZeroYPoints"), type = "line", color = "yellow", resizeable = True) self.ChiTauPlot.title = "Chi/Tau Plot" self.ChiTauPlot.x_axis.title = "Velocity (km/s)" self.ChiTauPlot.y_axis.title = "Height (Mm)" self.ChiTauPlot.range2d.x_range.set_bounds(self.new_vaxis[0], self.new_vaxis[-1]) self.ChiTauPlot.range2d.y_range.set_bounds(self.new_height[0], self.new_height[-1]) self.ChiTauPlotC = OverlayPlotContainer() self.ChiTauPlotC.add(self.ChiTauPlot) #------------------Create source function plot------------------------- sourceSF = S[:, ::-1] new_sourceSF = lineformInterpolate2D(vaxis, height, sourceSF, self.new_vaxis , self.new_height) self._image_indexSF = GridDataSource(xdata = self.new_vaxis, ydata = self.new_height) index_mapperSF = GridMapper(range = DataRange2D(self._image_indexSF)) self._image_valueSF = ImageData(data = new_sourceSF, value_depth = 1) color_mapperSF = jet(DataRange1D(self._image_valueSF)) self.SourceFuncPlotData = ArrayPlotData(imagedata = new_sourceSF, colormap = color_mapperSF, index = vaxis, TauOne = tau_one, Velocity = vz, Height = height, T = T/1e3, VelocityZeroXPoints = VelocityZeroXPoints, VelocityZeroYPoints = VelocityZeroYPoints) self.SourceFuncPlot = Plot(self.SourceFuncPlotData) self.SourceFuncPlot.img_plot1 = self.SourceFuncPlot.img_plot("imagedata", colormap = color_mapperSF, xbounds = (self.new_vaxis[0], self.new_vaxis[-1]), ybounds = (self.new_height[0], self.new_height[-1]))[0] self.SourceFuncPlot.overlays.append(ZoomTool(self.SourceFuncPlot.img_plot1)) self.SourceFuncPlot.tools.append(PanTool(self.SourceFuncPlot.img_plot1, drag_button="right")) self.SourceFuncPlot.TauOnePlot = self.SourceFuncPlot.plot(("index","TauOne"), type = "line", color = "red") self.SourceFuncPlot.VelocityPlot = self.SourceFuncPlot.plot(("Velocity","Height"), type = "line", color = "green", resizeable = True) self.SourceFuncPlot.VelocityZeroPlot = self.SourceFuncPlot.plot(("VelocityZeroXPoints","VelocityZeroYPoints"), type = "line", color = "yellow", resizeable = True) self.TemperaturePlotData = ArrayPlotData(T = T/1e3, Sline = Sline/1e3, Height = height) self.TemperaturePlot = Plot(self.TemperaturePlotData) self.TemperaturePlot.TPlot = self.TemperaturePlot.plot(("T","Height"), type = "line", color = "white", resizeable = True, line_style = 'dot', origin = 'bottom right') self.TemperaturePlot.Slinelot = self.TemperaturePlot.plot(("Sline","Height"), type = "line", color = "white", resizeable = True, line_style = 'dash', origin = 'bottom right') self.TemperaturePlot.x_grid.visible = False self.TemperaturePlot.y_grid.visible = False self.TemperaturePlot.x_axis.orientation = 'top' self.TemperaturePlot.y_axis.visible = False self.TemperaturePlot.range2d.x_range.set_bounds(0,30) self.TemperaturePlot.x_axis.title = "T (kK)" self.TemperaturePlot.default_origin = 'bottom right' self.TemperaturePlot.y_mapper = self.SourceFuncPlot.y_mapper self.SourceFuncPlotC = OverlayPlotContainer() self.SourceFuncPlotC.add(self.SourceFuncPlot) self.SourceFuncPlotC.add(self.TemperaturePlot) self.SourceFuncPlot.title = "Source Function Plot" self.SourceFuncPlot.x_axis.title = "Velocity (km/s)" self.SourceFuncPlot.y_axis.title = "Height (Mm)" self.SourceFuncPlot.range2d.x_range.set_bounds(self.new_vaxis[0], self.new_vaxis[-1]) self.SourceFuncPlot.range2d.y_range.set_bounds(self.new_height[0], self.new_height[-1]) #---------------------Create Tau * Exp(-tau) plot--------------------- tauCalcTE = (tau*N.exp(-tau)) tauCalcTE = tauCalcTE[:, ::-1] new_tauCalcTE = lineformInterpolate2D(vaxis, height, tauCalcTE, self.new_vaxis, self.new_height) self._image_indexTE = GridDataSource(xdata = self.new_vaxis, ydata = self.new_height) index_mapperTE = GridMapper(range = DataRange2D(self._image_indexTE)) self._image_valueTE = ImageData(data = new_tauCalcTE, value_depth = 1) color_mapperTE = jet(DataRange1D(self._image_valueTE)) self.TauExpPlotData = ArrayPlotData(imagedata = new_tauCalcTE, colormap = color_mapperTE, index = vaxis, TauOne = tau_one, Velocity = vz, Height = height, VelocityZeroXPoints = VelocityZeroXPoints, VelocityZeroYPoints = VelocityZeroYPoints) self.TauExpPlot = Plot(self.TauExpPlotData) self.TauExpPlot.img_plot1 = self.TauExpPlot.img_plot("imagedata", colormap = color_mapperTE, xbounds = (self.new_vaxis[0], self.new_vaxis[-1]), ybounds = (self.new_height[0], self.new_height[-1]))[0] self.TauExpPlot.overlays.append(ZoomTool(self.TauExpPlot.img_plot1)) self.TauExpPlot.tools.append(PanTool(self.TauExpPlot.img_plot1, drag_button="right")) self.TauExpPlot.TauOnePlot = self.TauExpPlot.plot(("index","TauOne"), type = "line", color = "red", resizeable = True) self.TauExpPlot.VelocityPlot = self.TauExpPlot.plot(("Velocity","Height"), type = "line", color = "green", resizeable = True) self.TauExpPlot.VelocityZeroPlot = self.TauExpPlot.plot(("VelocityZeroXPoints","VelocityZeroYPoints"), type = "line", color = "yellow", resizeable = True) self.TauExpPlot.title = "Tau * Exp Plot" self.TauExpPlot.x_axis.title = "Velocity (km/s)" self.TauExpPlot.y_axis.title = "Height (Mm)" self.TauExpPlot.range2d.x_range.set_bounds(self.new_vaxis[0], self.new_vaxis[-1]) self.TauExpPlot.range2d.y_range.set_bounds(self.new_height[0], self.new_height[-1]) self.TauExpPlotC = OverlayPlotContainer() self.TauExpPlotC.add(self.TauExpPlot) #--------------------Create Contribution Function Plot------------------------ new_tau_oneCF = lineformInterpolate1D(vaxis, tau_one, self.new_vaxis) new_vzCF = lineformInterpolate1D(height, vz, self.new_height) new_bint = lineformInterpolate1D(vaxis, bint, self.new_vaxis) ContributionFuncCF = (chi*N.exp(-tau)*S)[:,::-1] ContributionFuncCF /= N.max(ContributionFuncCF, axis=0) new_ContributionPlotCF = lineformInterpolate2D(vaxis, height, ContributionFuncCF, self.new_vaxis , self.new_height) self._image_indexCF = GridDataSource(xdata = self.new_vaxis, ydata = self.new_height) index_mapperCF = GridMapper(range = DataRange2D(self._image_indexCF)) self._image_valueCF = ImageData(data = new_ContributionPlotCF, value_depth = 1) color_mapperCF = jet(DataRange1D(self._image_valueCF)) self.ContributionFuncPlotData = ArrayPlotData(imagedata = new_ContributionPlotCF, colormap = color_mapperCF, index = vaxis, TauOne = tau_one, Velocity = vz, Height = height, VelocityZeroXPoints = VelocityZeroXPoints, VelocityZeroYPoints = VelocityZeroYPoints) self.ContributionFuncPlot = Plot(self.ContributionFuncPlotData) self.ContributionFuncPlot.img_plot1 = self.ContributionFuncPlot.img_plot("imagedata", colormap = color_mapperCF, xbounds = (self.new_vaxis[0], self.new_vaxis[-1]), ybounds = (self.new_height[0], self.new_height[-1]))[0] self.ContributionFuncPlot.overlays.append(ZoomTool(self.ContributionFuncPlot.img_plot1)) self.ContributionFuncPlot.tools.append(PanTool(self.ContributionFuncPlot.img_plot1, drag_button="right")) self.ContributionFuncPlot.TauOnePlot = self.ContributionFuncPlot.plot(("index","TauOne"), type = "line", color = "red", resizeable = True) self.ContributionFuncPlot.VelocityPlot = self.ContributionFuncPlot.plot(("Velocity","Height"), type = "line", color = "green", resizeable = True) self.ContributionFuncPlot.VelocityZeroPlot = self.ContributionFuncPlot.plot(("VelocityZeroXPoints","VelocityZeroYPoints"), type = "line", color = "yellow", resizeable = True) self.IntensityPlotData = ArrayPlotData(index = self.new_vaxis, bint = new_bint) self.IntensityPlot = Plot(self.IntensityPlotData) self.IntensityPlot.intensity = self.IntensityPlot.plot(("index","bint"), color = 'white', line_width = 2.0) self.IntensityPlot.y_axis.orientation = 'right' self.IntensityPlot.y_axis.title = "I_v (kK)" self.IntensityPlot.default_origin = 'bottom right' self.IntensityPlot.x_grid.visible = False self.IntensityPlot.y_grid.visible = False self.IntensityPlot.x_axis.visible = False self.IntensityPlot.x_axis = self.ContributionFuncPlot.x_axis self.IntensityPlot.range2d.y_range.set_bounds(3,7) #right_axis = LabelAxis(IntensityPlot, orientation = 'right') #IntensityPlot.underlays.append(right_axis) self.ContributionFuncPlot.title = "Contribution Function Plot" self.ContributionFuncPlot.x_axis.title = "Velocity (km/s)" self.ContributionFuncPlot.y_axis.title = "Height (Mm)" self.ContributionFuncPlot.range2d.x_range.set_bounds(self.new_vaxis[0], self.new_vaxis[-1]) self.ContributionFuncPlot.range2d.y_range.set_bounds(self.new_height[0], self.new_height[-1]) self.ContributionFuncPlotC = OverlayPlotContainer() self.ContributionFuncPlotC.add(self.ContributionFuncPlot) self.ContributionFuncPlotC.add(self.IntensityPlot) #-------------------------------Final Container Construction------------------------------- self.TauExpPlot.range2d = self.ChiTauPlot.range2d self.ContributionFuncPlot.range2d = self.ChiTauPlot.range2d self.SourceFuncPlot.range2d = self.ChiTauPlot.range2d self.LeftPlots = VPlotContainer(self.TauExpPlotC, self.ChiTauPlotC, background = "lightgray", use_back_buffer = True) self.LeftPlots.spacing = 0 self.RightPlots = VPlotContainer(self.ContributionFuncPlotC, self.SourceFuncPlotC, background = "lightgray", use_back_buffer = True) self.RightPlots.spacing = 0 MainContainer = HPlotContainer(self.LeftPlots, self.RightPlots, background = "lightgray", use_back_buffer = True) MainContainer.spacing = 0 self.PrimaryPlotC = MainContainer
def create_PrimaryPlotC(self): #Extracts the data for the main plot self.MainPlotData = self.IntensityData[:,:,self.intensityindex] self.markerplotdatax = [] self.markerplotdatay = [] self.SpectraMultiple = 1.0e+8 WavelengthXPoints = [self.Wavelength, self.Wavelength] WavelengthYPoints = [N.min(self.IntensityData[:,:])*self.SpectraMultiple, N.max(self.IntensityData[:,:])*self.SpectraMultiple] WavelengthXPointsStatic = WavelengthXPoints WavelengthYPointsStatic = WavelengthYPoints AvgIntensity = N.mean(N.mean(self.IntensityData, axis = 0), axis = 0) print "mean computed-------------------" #Create main Plot (intensity plot) self.Mainplotdata = ArrayPlotData(Mainimagedata = self.MainPlotData, markerplotdatax = self.markerplotdatax, markerplotdatay = self.markerplotdatay) self.Mainplot = Plot(self.Mainplotdata) self.Main_img_plot = self.Mainplot.img_plot("Mainimagedata", colormap = jet)[0] #Create marker wneh x is pressed self.Mainplot.MarkerPlot = self.Mainplot.plot(("markerplotdatax","markerplotdatay"),type = 'line', color = 'white') #Create overlaid crosshairs for Main plot LineInspector1 = LineInspector(component = self.Main_img_plot,axis = 'index_x', write_metadata=True,is_listener = False,inspect_mode="indexed") self.Main_img_plot.overlays.append(LineInspector1) LineInspector2 = LineInspector(component = self.Main_img_plot,axis = 'index_y', write_metadata=True,is_listener = False,inspect_mode="indexed") self.Main_img_plot.overlays.append(LineInspector2) #Create overlay tools and add them to main plot Main_imgtool = ImageInspectorTool(self.Main_img_plot) self.Main_img_plot.tools.append(Main_imgtool) Main_overlay = ImageInspectorOverlay(component = self.Main_img_plot, image_inspector = Main_imgtool, bgcolor = "white", border_visible = True) self.Main_img_plot.overlays.append(Main_overlay) #Sync up inspector position so it can be passed to the spectra plot Main_overlay.sync_trait('InspectorPosition', self, 'InspectorPosition', mutual = True) Main_imgtool.sync_trait('ImageLock', self, 'ImageLock') Main_imgtool.sync_trait('SaveFlag', self, 'SaveFlag') #Sync up max and min colormap value self.Main_img_plot.value_range.sync_trait('low', self, 'colormapmin', mutual = True) self.Main_img_plot.value_range.sync_trait('high', self, 'colormapmax', mutual = True) #Create spectra plot for a single column self.Spectraplotdata = ArrayPlotData(x = self.WavelengthData[:], y = (self.IntensityData[2,2] * self.SpectraMultiple), WavelengthXPointsStatic = WavelengthXPointsStatic, WavelengthYPointsStatic = WavelengthYPointsStatic, WavelengthXPoints = WavelengthXPoints, WavelengthYPoints = WavelengthYPoints, AvgIntensity = AvgIntensity * self.SpectraMultiple, is_listener = True) self.Spectraplot1 = Plot(self.Spectraplotdata) self.Spectraplot1.plot(("x","y"), type = "line", color = "blue") self.Spectraplot1.plot( ("WavelengthXPointsStatic","WavelengthYPointsStatic"), type = 'line', line_style = 'dash', color = 'green') self.Spectraplot1.plot( ("WavelengthXPoints","WavelengthYPoints"), type = 'line', line_style = 'dash', color = 'red') self.Spectraplot1.plot( ("x","AvgIntensity"), type = 'line', color = 'black') #Change Plot characteristics #Sets width around waveref to examine self.xlowspread = 1. self.xhighspread = 1. self.Spectraplot1.range2d.x_range.set_bounds(self.wave_ref - self.xlowspread, self.wave_ref + self.xhighspread) self.Spectraplot1.x_axis.title = "Wavelength (A)" self.Spectraplot1.y_axis.title = "Intensity (J s^-1 m^-2 Hz^-1 sr^-1)" self.rangearray = self.IntensityData[:,:] self.rangearray = self.rangearray[:,:,N.argmin(N.abs(self.WavelengthData[:]-(self.wave_ref-self.xlowspread))):N.argmin(N.abs(self.WavelengthData[:]-(self.wave_ref+self.xhighspread)))] self.Spectraplot1.range2d.y_range.set_bounds(N.min(self.rangearray[:,:])*self.SpectraMultiple, N.max(self.rangearray[:,:]) * self.SpectraMultiple) #self.Spectraplot1.range2d.y_range.set_bounds(N.min(self.rangearray[:,:])*self.SpectraMultiple, Scaling * (N.max(self.rangearray[:,:]) - N.min(self.rangearray[:,:])) + N.min(self.rangearray[:,:]) * self.SpectraMultiple) #add some standard tools. Note, I'm assigning the PanTool to the #right mouse-button to avoid conflicting with the cursors self.Mainplot.tools.append(PanTool(self.Main_img_plot, drag_button="right")) self.Spectraplot1.tools.append(PanTool(self.Spectraplot1, drag_button="right")) self.Mainplot.overlays.append(ZoomTool(self.Main_img_plot)) self.Spectraplot1.overlays.append(ZoomTool(self.Spectraplot1)) #Changing interactive options zoom = ZoomTool(component=self.Mainplot, tool_mode="box", always_on=False) #Create Container for main plot MainContainer = HPlotContainer(self.Mainplot, self.Spectraplot1, background = "lightgray", use_back_buffer = True) MainContainer.spacing = 25 self.PrimaryPlotC = MainContainer