def get_contour_line_plot(): NPOINTS_X, NPOINTS_Y = 600, 300 # Create a scalar field to contour xs = np.linspace(-2 * np.pi, +2 * np.pi, NPOINTS_X) ys = np.linspace(-1.5 * np.pi, +1.5 * np.pi, NPOINTS_Y) x, y = np.meshgrid(xs, ys) z = scipy.special.jn(2, x) * y * x index = GridDataSource(xdata=xs, ydata=ys) index_mapper = GridMapper(range=DataRange2D(index)) value = ImageData(data=z, value_depth=1) color_mapper = dc.Blues(DataRange1D(value)) contour_plot = ContourLinePlot(index=index, index_mapper=index_mapper, value=value, colors=color_mapper, widths=list(range(1, 11)), **PLOT_DEFAULTS) add_axes(contour_plot, x_label='x', y_label='y') return contour_plot
def get_contour_poly_plot(): NPOINTS_X, NPOINTS_Y = 600, 300 # Create a scalar field to contour xs = np.linspace(-2 * np.pi, +2 * np.pi, NPOINTS_X) ys = np.linspace(-1.5 * np.pi, +1.5 * np.pi, NPOINTS_Y) x, y = np.meshgrid(xs, ys) z = scipy.special.jn(2, x) * y * x # FIXME: we have set the xbounds and ybounds manually to work around # a bug in CountourLinePlot, see comment in contour_line_plot.py at # line 112 (the workaround is the +1 at the end) xs_bounds = np.linspace(xs[0], xs[-1], z.shape[1] + 1) ys_bounds = np.linspace(ys[0], ys[-1], z.shape[0] + 1) index = GridDataSource(xdata=xs_bounds, ydata=ys_bounds) index_mapper = GridMapper(range=DataRange2D(index)) value = ImageData(data=z, value_depth=1) color_mapper = dc.Blues(DataRange1D(value)) contour_plot = ContourPolyPlot(index=index, index_mapper=index_mapper, value=value, colors=color_mapper, **PLOT_DEFAULTS) add_axes(contour_plot, x_label='x', y_label='y') return contour_plot