def test__grid_scatterer__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.grid_scatterer.size == 14 assert plotter.grid_scatterer.marker == "x" assert plotter.grid_scatterer.colors == ["y"] plotter = aplt.Plotter( grid_scatterer=aplt.GridScatterer(size=1, marker="x", colors="k")) assert plotter.grid_scatterer.size == 1 assert plotter.grid_scatterer.marker == "x" assert plotter.grid_scatterer.colors == ["k"] sub_plotter = aplt.SubPlotter() assert sub_plotter.grid_scatterer.size == 6 assert sub_plotter.grid_scatterer.marker == "." assert sub_plotter.grid_scatterer.colors == ["r"] sub_plotter = aplt.SubPlotter(grid_scatterer=aplt.GridScatterer.sub( marker="o", colors=["r", "b"])) assert sub_plotter.grid_scatterer.size == 6 assert sub_plotter.grid_scatterer.marker == "o" assert sub_plotter.grid_scatterer.colors == ["r", "b"]
def test__positions_scatterer__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.positions_scatterer.size == 15 assert plotter.positions_scatterer.marker == "o" assert plotter.positions_scatterer.colors == ["r", "g", "b"] plotter = aplt.Plotter(positions_scatterer=aplt.PositionsScatterer( size=1, marker="x", colors="k")) assert plotter.positions_scatterer.size == 1 assert plotter.positions_scatterer.marker == "x" assert plotter.positions_scatterer.colors == ["k"] sub_plotter = aplt.SubPlotter() assert sub_plotter.positions_scatterer.size == 5 assert sub_plotter.positions_scatterer.marker == "." assert sub_plotter.positions_scatterer.colors == ["c", "g", "b"] sub_plotter = aplt.SubPlotter( positions_scatterer=aplt.PositionsScatterer.sub(marker="o", colors=["r", "b"])) assert sub_plotter.positions_scatterer.size == 5 assert sub_plotter.positions_scatterer.marker == "o" assert sub_plotter.positions_scatterer.colors == ["r", "b"]
def test__mask_scatterer__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.mask_scatterer.size == 12 assert plotter.mask_scatterer.marker == "." assert plotter.mask_scatterer.colors == ["g"] plotter = aplt.Plotter( mask_scatterer=aplt.MaskScatterer(size=1, marker="x", colors="k")) assert plotter.mask_scatterer.size == 1 assert plotter.mask_scatterer.marker == "x" assert plotter.mask_scatterer.colors == ["k"] sub_plotter = aplt.SubPlotter() assert sub_plotter.mask_scatterer.size == 8 assert sub_plotter.mask_scatterer.marker == "." assert sub_plotter.mask_scatterer.colors == ["w"] sub_plotter = aplt.SubPlotter(mask_scatterer=aplt.MaskScatterer.sub( marker="o", colors=["r", "b"])) assert sub_plotter.mask_scatterer.size == 8 assert sub_plotter.mask_scatterer.marker == "o" assert sub_plotter.mask_scatterer.colors == ["r", "b"]
def test__border_scatterer__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.border_scatterer.size == 13 assert plotter.border_scatterer.marker == "+" assert plotter.border_scatterer.colors == ["c"] plotter = aplt.Plotter(border_scatterer=aplt.BorderScatterer( size=1, marker="x", colors="k")) assert plotter.border_scatterer.size == 1 assert plotter.border_scatterer.marker == "x" assert plotter.border_scatterer.colors == ["k"] sub_plotter = aplt.SubPlotter() assert sub_plotter.border_scatterer.size == 7 assert sub_plotter.border_scatterer.marker == "." assert sub_plotter.border_scatterer.colors == ["k"] sub_plotter = aplt.SubPlotter( border_scatterer=aplt.BorderScatterer.sub(marker="o", colors=["r", "b"])) assert sub_plotter.border_scatterer.size == 7 assert sub_plotter.border_scatterer.marker == "o" assert sub_plotter.border_scatterer.colors == ["r", "b"]
def test__origin_scatterer__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.origin_scatterer.size == 80 assert plotter.origin_scatterer.marker == "x" assert plotter.origin_scatterer.colors == ["k"] plotter = aplt.Plotter(origin_scatterer=aplt.OriginScatterer( size=1, marker=".", colors="k")) assert plotter.origin_scatterer.size == 1 assert plotter.origin_scatterer.marker == "." assert plotter.origin_scatterer.colors == ["k"] sub_plotter = aplt.SubPlotter() assert sub_plotter.origin_scatterer.size == 81 assert sub_plotter.origin_scatterer.marker == "." assert sub_plotter.origin_scatterer.colors == ["r"] sub_plotter = aplt.SubPlotter( origin_scatterer=aplt.OriginScatterer.sub(marker="o", colors=["r", "b"])) assert sub_plotter.origin_scatterer.size == 81 assert sub_plotter.origin_scatterer.marker == "o" assert sub_plotter.origin_scatterer.colors == ["r", "b"]
def test__units__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.units.use_scaled == True assert plotter.units.in_kpc == False assert plotter.units.conversion_factor == None plotter = aplt.Plotter( units=aplt.Units(in_kpc=True, conversion_factor=2.0)) assert plotter.units.use_scaled == True assert plotter.units.in_kpc == True assert plotter.units.conversion_factor == 2.0 sub_plotter = aplt.SubPlotter() assert sub_plotter.units.use_scaled == True assert sub_plotter.units.in_kpc == False assert sub_plotter.units.conversion_factor == None sub_plotter = aplt.SubPlotter( units=aplt.Units(use_scaled=False, conversion_factor=2.0)) assert sub_plotter.units.use_scaled == False assert sub_plotter.units.in_kpc == False assert sub_plotter.units.conversion_factor == 2.0
def test__voronoi_drawer__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.voronoi_drawer.edgewidth == 0.3 assert plotter.voronoi_drawer.edgecolor == "k" assert plotter.voronoi_drawer.alpha == 0.7 plotter = aplt.Plotter(voronoi_drawer=aplt.VoronoiDrawer( edgewidth=0.5, edgecolor="r", alpha=1.0)) assert plotter.voronoi_drawer.edgewidth == 0.5 assert plotter.voronoi_drawer.edgecolor == "r" assert plotter.voronoi_drawer.alpha == 1.0 sub_plotter = aplt.SubPlotter() assert sub_plotter.voronoi_drawer.edgewidth == 1.0 assert sub_plotter.voronoi_drawer.edgecolor == "r" assert sub_plotter.voronoi_drawer.alpha == 0.5 sub_plotter = aplt.SubPlotter( voronoi_drawer=aplt.VoronoiDrawer.sub(edgecolor="r", alpha=1.0)) assert sub_plotter.voronoi_drawer.edgewidth == 1.0 assert sub_plotter.voronoi_drawer.edgecolor == "r" assert sub_plotter.voronoi_drawer.alpha == 1.0
def test__liner__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.liner.width == 3 assert plotter.liner.style == "-" assert plotter.liner.colors == ["k", "w"] assert plotter.liner.pointsize == 2 plotter = aplt.Plotter(liner=aplt.Liner( width=1, style=".", colors=["k", "b"], pointsize=3)) assert plotter.liner.width == 1 assert plotter.liner.style == "." assert plotter.liner.colors == ["k", "b"] assert plotter.liner.pointsize == 3 sub_plotter = aplt.SubPlotter() assert sub_plotter.liner.width == 1 assert sub_plotter.liner.style == "-" assert sub_plotter.liner.colors == ["k"] assert sub_plotter.liner.pointsize == 20 sub_plotter = aplt.SubPlotter( liner=aplt.Liner.sub(style=".", colors="r", pointsize=21)) assert sub_plotter.liner.width == 1 assert sub_plotter.liner.style == "." assert sub_plotter.liner.colors == ["r"] assert sub_plotter.liner.pointsize == 21
def test__ticks__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.ticks.ysize == 14 assert plotter.ticks.xsize == 15 assert plotter.ticks.y_manual == None assert plotter.ticks.x_manual == None plotter = aplt.Plotter(ticks=aplt.Ticks( ysize=24, xsize=25, y_manual=[1.0, 2.0], x_manual=[3.0, 4.0])) assert plotter.ticks.ysize == 24 assert plotter.ticks.xsize == 25 assert plotter.ticks.y_manual == [1.0, 2.0] assert plotter.ticks.x_manual == [3.0, 4.0] sub_plotter = aplt.SubPlotter() assert sub_plotter.ticks.ysize == 24 assert sub_plotter.ticks.xsize == 25 assert sub_plotter.ticks.y_manual == None assert sub_plotter.ticks.x_manual == None sub_plotter = aplt.SubPlotter(ticks=aplt.Ticks.sub( xsize=25, y_manual=[1.0, 2.0], x_manual=[3.0, 4.0])) assert sub_plotter.ticks.ysize == 24 assert sub_plotter.ticks.xsize == 25 assert sub_plotter.ticks.y_manual == [1.0, 2.0] assert sub_plotter.ticks.x_manual == [3.0, 4.0]
def test__output__correctly(self): plotter = aplt.Plotter() assert plotter.output.path == None assert plotter.output._format == None assert plotter.output.format == "show" assert plotter.output.filename == None plotter = aplt.Plotter( output=aplt.Output(path="Path", format="png", filename="file")) assert plotter.output.path == "Path" assert plotter.output._format == "png" assert plotter.output.format == "png" assert plotter.output.filename == "file" sub_plotter = aplt.SubPlotter() assert sub_plotter.output.path == None assert sub_plotter.output._format == None assert sub_plotter.output.format == "show" assert sub_plotter.output.filename == None sub_plotter = aplt.SubPlotter( output=aplt.Output(path="Path", format="png", filename="file")) assert sub_plotter.output.path == "Path" assert sub_plotter.output._format == "png" assert sub_plotter.output.format == "png" assert sub_plotter.output.filename == "file"
def test__image_and_mapper_subplot_is_output_for_all_mappers( imaging_7x7, rectangular_mapper_7x7_3x3, voronoi_mapper_9_3x3, plot_path, plot_patch): aplt.mapper.subplot_image_and_mapper( image=imaging_7x7.image, mapper=rectangular_mapper_7x7_3x3, include=aplt.Include(inversion_pixelization_grid=True, inversion_grid=True, inversion_border=True), image_pixel_indexes=[[0, 1, 2], [3]], source_pixel_indexes=[[1, 2], [0]], sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "subplot_image_and_mapper.png" in plot_patch.paths aplt.mapper.subplot_image_and_mapper( image=imaging_7x7.image, mapper=voronoi_mapper_9_3x3, include=aplt.Include(inversion_pixelization_grid=True, inversion_grid=True, inversion_border=True), image_pixel_indexes=[[0, 1, 2], [3]], source_pixel_indexes=[[1, 2], [0]], sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "subplot_image_and_mapper.png" in plot_patch.paths
def test__pixelization_grid_scatterer__from_config_or_via_manual_input( self): plotter = aplt.Plotter() assert plotter.pixelization_grid_scatterer.size == 5 assert plotter.pixelization_grid_scatterer.marker == "." assert plotter.pixelization_grid_scatterer.colors == ["r"] plotter = aplt.Plotter( pixelization_grid_scatterer=aplt.PixelizationGridScatterer( size=1, marker="x", colors="k")) assert plotter.pixelization_grid_scatterer.size == 1 assert plotter.pixelization_grid_scatterer.marker == "x" assert plotter.pixelization_grid_scatterer.colors == ["k"] sub_plotter = aplt.SubPlotter() assert sub_plotter.pixelization_grid_scatterer.size == 6 assert sub_plotter.pixelization_grid_scatterer.marker == "o" assert sub_plotter.pixelization_grid_scatterer.colors == ["g"] sub_plotter = aplt.SubPlotter( pixelization_grid_scatterer=aplt.PixelizationGridScatterer.sub( marker="o", colors="r")) assert sub_plotter.pixelization_grid_scatterer.size == 6 assert sub_plotter.pixelization_grid_scatterer.marker == "o" assert sub_plotter.pixelization_grid_scatterer.colors == ["r"]
def test__index_scatterer__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.index_scatterer.size == 20 assert plotter.index_scatterer.marker == "." assert plotter.index_scatterer.colors == ["r", "g", "b", "y", "k", "w"] plotter = aplt.Plotter(index_scatterer=aplt.IndexScatterer( size=1, marker="x", colors="k")) assert plotter.index_scatterer.size == 1 assert plotter.index_scatterer.marker == "x" assert plotter.index_scatterer.colors == ["k"] sub_plotter = aplt.SubPlotter() assert sub_plotter.index_scatterer.size == 21 assert sub_plotter.index_scatterer.marker == "+" assert sub_plotter.index_scatterer.colors == [ "r", "g", "b", "y", "w", "k" ] sub_plotter = aplt.SubPlotter( index_scatterer=aplt.IndexScatterer.sub(marker="o", colors="r")) assert sub_plotter.index_scatterer.size == 21 assert sub_plotter.index_scatterer.marker == "o" assert sub_plotter.index_scatterer.colors == ["r"]
def test__subplot_figsize_for_number_of_subplots(self): plotter = aplt.SubPlotter() figsize = plotter.get_subplot_figsize(number_subplots=1) assert figsize == (18, 8) figsize = plotter.get_subplot_figsize(number_subplots=4) assert figsize == (13, 10) plotter = aplt.SubPlotter(figure=aplt.Figure(figsize=(20, 20))) figsize = plotter.get_subplot_figsize(number_subplots=4) assert figsize == (20, 20)
def test__fit_sub_plot(fit_interferometer_7, plot_path, plot_patch): aplt.fit_interferometer.subplot_fit_interferometer( fit=fit_interferometer_7, sub_plotter=aplt.SubPlotter( output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subplot_fit_interferometer.png" in plot_patch.paths
def test__subplot_is_output(interferometer_7, plot_path, plot_patch): aplt.interferometer.subplot_interferometer( interferometer=interferometer_7, sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "subplot_interferometer.png" in plot_patch.paths
def test__colormap__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.cmap.cmap == "jet" assert plotter.cmap.norm == "linear" assert plotter.cmap.norm_min == None assert plotter.cmap.norm_max == None assert plotter.cmap.linthresh == 1.0 assert plotter.cmap.linscale == 2.0 plotter = aplt.Plotter(cmap=aplt.ColorMap( cmap="cold", norm="log", norm_min=0.1, norm_max=1.0, linthresh=1.5, linscale=2.0, )) assert plotter.cmap.cmap == "cold" assert plotter.cmap.norm == "log" assert plotter.cmap.norm_min == 0.1 assert plotter.cmap.norm_max == 1.0 assert plotter.cmap.linthresh == 1.5 assert plotter.cmap.linscale == 2.0 sub_plotter = aplt.SubPlotter() assert sub_plotter.cmap.cmap == "jet" assert sub_plotter.cmap.norm == "linear" assert sub_plotter.cmap.norm_min == None assert sub_plotter.cmap.norm_max == None assert sub_plotter.cmap.linthresh == 1.0 assert sub_plotter.cmap.linscale == 2.0 sub_plotter = aplt.SubPlotter(cmap=aplt.ColorMap.sub( cmap="cold", norm="log", norm_min=0.1, norm_max=1.0, linscale=2.0)) assert sub_plotter.cmap.cmap == "cold" assert sub_plotter.cmap.norm == "log" assert sub_plotter.cmap.norm_min == 0.1 assert sub_plotter.cmap.norm_max == 1.0 assert sub_plotter.cmap.linthresh == 1.0 assert sub_plotter.cmap.linscale == 2.0
def test__subplot_is_output(imaging_7x7, positions_7x7, mask_7x7, plot_path, plot_patch): aplt.imaging.subplot_imaging( imaging=imaging_7x7, sub_plotter=aplt.SubPlotter( output=aplt.Output(plot_path, format="png")), ) assert plot_path + "subplot_imaging.png" in plot_patch.paths
def test__fit_sub_plot(fit_imaging_7x7, plot_path, plot_patch): aplt.fit_imaging.subplot_fit_imaging( fit=fit_imaging_7x7, include=aplt.Include(mask=True), sub_plotter=aplt.SubPlotter( output=aplt.Output(path=plot_path, format="png")), ) assert plot_path + "subplot_fit_imaging.png" in plot_patch.paths
def test__labels__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.labels.title == None assert plotter.labels._yunits == None assert plotter.labels._xunits == None assert plotter.labels.titlesize == 11 assert plotter.labels.ysize == 12 assert plotter.labels.xsize == 13 plotter = aplt.Plotter(labels=aplt.Labels(title="OMG", yunits="hi", xunits="hi2", titlesize=1, ysize=2, xsize=3)) assert plotter.labels.title == "OMG" assert plotter.labels._yunits == "hi" assert plotter.labels._xunits == "hi2" assert plotter.labels.titlesize == 1 assert plotter.labels.ysize == 2 assert plotter.labels.xsize == 3 sub_plotter = aplt.SubPlotter() assert sub_plotter.labels.title == None assert sub_plotter.labels._yunits == None assert sub_plotter.labels._xunits == None assert sub_plotter.labels.titlesize == 15 assert sub_plotter.labels.ysize == 22 assert sub_plotter.labels.xsize == 23 sub_plotter = aplt.SubPlotter(labels=aplt.Labels.sub( title="OMG", yunits="hi", xunits="hi2", ysize=2, xsize=3)) assert sub_plotter.labels.title == "OMG" assert sub_plotter.labels._yunits == "hi" assert sub_plotter.labels._xunits == "hi2" assert sub_plotter.labels.titlesize == 15 assert sub_plotter.labels.ysize == 2 assert sub_plotter.labels.xsize == 3
def test__figure__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.figure.figsize == (7, 7) assert plotter.figure.aspect == "auto" plotter = aplt.Plotter(figure=aplt.Figure(aspect="auto")) assert plotter.figure.figsize == (7, 7) assert plotter.figure.aspect == "auto" sub_plotter = aplt.SubPlotter() assert sub_plotter.figure.figsize == None assert sub_plotter.figure.aspect == "square" sub_plotter = aplt.SubPlotter(figure=aplt.Figure.sub(figsize=(6, 6))) assert sub_plotter.figure.figsize == (6, 6) assert sub_plotter.figure.aspect == "square"
def test__legend__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.legend.include == True assert plotter.legend.fontsize == 12 plotter = aplt.Plotter(legend=aplt.Legend(include=False, fontsize=11)) assert plotter.legend.include == False assert plotter.legend.fontsize == 11 sub_plotter = aplt.SubPlotter() assert sub_plotter.legend.include == False assert sub_plotter.legend.fontsize == 13 sub_plotter = aplt.SubPlotter(legend=aplt.Legend.sub(include=True)) assert sub_plotter.legend.include == True assert sub_plotter.legend.fontsize == 13
def test__plotter_number_of_subplots(self): plotter = aplt.SubPlotter() rows, columns = plotter.get_subplot_rows_columns(number_subplots=1) assert rows == 1 assert columns == 2 rows, columns = plotter.get_subplot_rows_columns(number_subplots=4) assert rows == 2 assert columns == 2
def test__colorbar__from_config_or_via_manual_input(self): plotter = aplt.Plotter() assert plotter.cb.ticksize == 1 assert plotter.cb.fraction == 3.0 assert plotter.cb.pad == 4.0 assert plotter.cb.tick_values == None assert plotter.cb.tick_labels == None plotter = aplt.Plotter(cb=aplt.ColorBar( ticksize=20, fraction=0.001, pad=10.0, tick_values=(1.0, 2.0), tick_labels=(3.0, 4.0), )) assert plotter.cb.ticksize == 20 assert plotter.cb.fraction == 0.001 assert plotter.cb.pad == 10.0 assert plotter.cb.tick_values == (1.0, 2.0) assert plotter.cb.tick_labels == (3.0, 4.0) sub_plotter = aplt.SubPlotter() assert sub_plotter.cb.ticksize == 1 assert sub_plotter.cb.fraction == 3.0 assert sub_plotter.cb.pad == 4.0 sub_plotter = aplt.SubPlotter( cb=aplt.ColorBar.sub(fraction=0.001, pad=10.0)) assert sub_plotter.cb.ticksize == 1 assert sub_plotter.cb.fraction == 0.001 assert sub_plotter.cb.pad == 10.0
def test__open_and_close_subplot_figures(self): plotter = aplt.Plotter() plotter.figure.open() assert plt.fignum_exists(num=1) == True plotter.figure.close() assert plt.fignum_exists(num=1) == False plotter = aplt.SubPlotter() assert plt.fignum_exists(num=1) == False plotter.open_subplot_figure(number_subplots=4) assert plt.fignum_exists(num=1) == True plotter.figure.close() assert plt.fignum_exists(num=1) == False
# (Note that you will need to reset your Juypter notebook server for these changes to take effect, so make sure # you have the right values using the function above beforehand!) # In addition to individual 'figures' which use a 'plotter' to plot them, PyAutoArray also plots 'subplots' using a # 'sub_plotter'. Lets plot a subplot of our imaging data: aplt.imaging.subplot_imaging(imaging=imaging) # Again, we can customize this subplot using a SubPlotter. # (The '.sub' ensures we load the setting values from the config file 'autolens_workspace/config/visualize/subplots.ini' sub_plotter = aplt.SubPlotter( figure=aplt.Figure.sub(figsize=(7, 7)), ticks=aplt.Ticks.sub(ysize=8, xsize=8), labels=aplt.Labels.sub(ysize=6, xsize=6, titlesize=12), ) aplt.imaging.subplot_imaging(imaging=imaging, sub_plotter=sub_plotter) # Again, you can customize the default appearance of subplots by editing the config file # autolens_workspace/config/visualize/subplots.ini'. # The other thing we can do with figures is choose what we include in the plot. For example, we can choose whether to # include the origin of the coordinate system on our plot of the image: aplt.imaging.image(imaging=imaging, plotter=plotter, include=aplt.Include(origin=True))