def _create_plot_component(): # Generate some data for the eye diagram. num_samples = 5000 samples_per_symbol = 24 y = demo_data(num_samples, samples_per_symbol) # Compute the eye diagram array. ybounds = (-0.25, 1.25) grid = grid_count(y, 2 * samples_per_symbol, offset=16, size=(480, 480), bounds=ybounds).T # Convert the array to floating point, and replace 0 with np.nan. # These points will be transparent in the image plot. grid = grid.astype(np.float32) grid[grid == 0] = np.nan #--------------------------------------------------------------------- # The rest of the function creates the chaco image plot. pd = ArrayPlotData() pd.set_data("eyediagram", grid) plot = Plot(pd) img_plot = plot.img_plot("eyediagram", xbounds=(0, 2), ybounds=ybounds, bgcolor=(0, 0, 0), colormap=cool)[0] # Tweak some of the plot properties plot.title = "Eye Diagram" plot.padding = 50 # Axis grids vgrid = PlotGrid(component=plot, mapper=plot.index_mapper, orientation='vertical', line_color='gray', line_style='dot') hgrid = PlotGrid(component=plot, mapper=plot.value_mapper, orientation='horizontal', line_color='gray', line_style='dot') plot.underlays.append(vgrid) plot.underlays.append(hgrid) # Add pan and zoom tools. plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=img_plot, tool_mode="box", always_on=False) img_plot.overlays.append(zoom) return plot
def _create_plot_component(): # Generate some data for the eye diagram. num_samples = 5000 samples_per_symbol = 24 y = demo_data(num_samples, samples_per_symbol) # Compute the eye diagram array. ybounds = (-0.25, 1.25) grid = grid_count(y, 2 * samples_per_symbol, offset=16, size=(480, 480), bounds=ybounds).T # Convert the array to floating point, and replace 0 with np.nan. # These points will be transparent in the image plot. grid = grid.astype(np.float32) grid[grid == 0] = np.nan # --------------------------------------------------------------------- # The rest of the function creates the chaco image plot. pd = ArrayPlotData() pd.set_data("eyediagram", grid) plot = Plot(pd) img_plot = plot.img_plot("eyediagram", xbounds=(0, 2), ybounds=ybounds, bgcolor=(0, 0, 0), colormap=cool)[0] # Tweak some of the plot properties plot.title = "Eye Diagram" plot.padding = 50 # Axis grids vgrid = PlotGrid( component=plot, mapper=plot.index_mapper, orientation="vertical", line_color="gray", line_style="dot" ) hgrid = PlotGrid( component=plot, mapper=plot.value_mapper, orientation="horizontal", line_color="gray", line_style="dot" ) plot.underlays.append(vgrid) plot.underlays.append(hgrid) # Add pan and zoom tools. plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=img_plot, tool_mode="box", always_on=False) img_plot.overlays.append(zoom) return plot
m = counts.max() colors = np.zeros((m+1, 4), dtype=np.uint8) r = np.linspace(color1[0], color2[0], m) g = np.linspace(color1[1], color2[1], m) b = np.linspace(color1[2], color2[2], m) colors[1:, 0] = r colors[1:, 1] = g colors[1:, 2] = b colors[1:, 3] = 255 colors[0, 3] = 0 img = colors[counts] return img # Generate image data y = demo_data(5000, 24) ybounds = (-0.25, 1.25) # Compute the eye diagram image data. counts = grid_count(y, 48, offset=16, size=(480, 480), bounds=ybounds) # Convert counts to an array of RGBA values. yellow = (224, 192, 48) img_data = colorize(counts, yellow) #------------------------------------------------------------------------- # The rest of this script uses pyqtgraph to create a plot # of the eye diagram. pg.mkQApp()
# Copyright (c) 2015, Warren Weckesser. All rights reserved. # This software is licensed according to the "BSD 2-clause" license. from eyediagram.demo_data import demo_data from eyediagram.mpl import eyediagram import matplotlib.pyplot as plt # Get some data for the demonstration. num_symbols = 5000 samples_per_symbol = 24 y = demo_data(num_symbols, samples_per_symbol) eyediagram(y, 2 * samples_per_symbol, offset=16, cmap=plt.cm.coolwarm) plt.show()
m = counts.max() colors = np.zeros((m + 1, 4), dtype=np.uint8) r = np.linspace(color1[0], color2[0], m) g = np.linspace(color1[1], color2[1], m) b = np.linspace(color1[2], color2[2], m) colors[1:, 0] = r colors[1:, 1] = g colors[1:, 2] = b colors[1:, 3] = 255 colors[0, 3] = 0 img = colors[counts] return img # Generate image data y = demo_data(5000, 24) ybounds = (-0.25, 1.25) # Compute the eye diagram image data. counts = grid_count(y, 48, offset=16, size=(480, 480), bounds=ybounds) # Convert counts to an array of RGBA values. yellow = (224, 192, 48) img_data = colorize(counts, yellow) #------------------------------------------------------------------------- # The rest of this script uses pyqtgraph to create a plot # of the eye diagram. pg.mkQApp()
# Copyright (c) 2015, Warren Weckesser. All rights reserved. # This software is licensed according to the "BSD 2-clause" license. from eyediagram.demo_data import demo_data from eyediagram.mpl import eyediagram import matplotlib.pyplot as plt # Get some data for the demonstration. num_symbols = 5000 samples_per_symbol = 24 y = demo_data(num_symbols, samples_per_symbol) eyediagram(y, 2*samples_per_symbol, offset=16, cmap=plt.cm.coolwarm) plt.show()