From d247b47fb6256b8d47193c18f63203c6aa1e5104 Mon Sep 17 00:00:00 2001 From: Egor Sobolev <egor.sobolev@xfel.eu> Date: Sat, 1 Jun 2024 22:41:37 +0200 Subject: [PATCH] Add option to draw data without antialiasing, and turn off colorbar --- src/geomtools/detector/draw.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/geomtools/detector/draw.py b/src/geomtools/detector/draw.py index dbc7846..c5f9c4b 100644 --- a/src/geomtools/detector/draw.py +++ b/src/geomtools/detector/draw.py @@ -1,6 +1,5 @@ -import numpy as np - import matplotlib.pyplot as plt +import numpy as np from mpl_toolkits.axes_grid1 import make_axes_locatable from .geom import assemble_data, get_pixel_positions @@ -32,8 +31,8 @@ def plot_detector_layout(panels, figsize=(16, 16), **kwargs): return fig, ax -def plot_data_on_detector(data, panels, figwidth=16, cmap=plt.cm.magma, - **kwargs): +def plot_data_on_detector(data, panels, colorbar=True, figwidth=16, + cmap=plt.cm.magma, **kwargs): """Plots data according to the detector geometry.""" if isinstance(panels, np.ndarray): @@ -51,15 +50,17 @@ def plot_data_on_detector(data, panels, figwidth=16, cmap=plt.cm.magma, extent = (nx - xc + 0.5, -xc - 0.5, -yc - 0.5, ny - yc + 0.5) im = ax.imshow(np.flip(img, axis=1), origin='lower', - extent=extent, vmin=0, vmax=1, cmap=cmap) + extent=extent, vmin=0, vmax=1, cmap=cmap, + interpolation="none") ax.plot([-50, 50], [0, 0], 'r') ax.plot([0, 0], [-50, 50], 'r') ax.set_aspect('equal') ax.axis(False) - ax_divider = make_axes_locatable(ax) - cax = ax_divider.append_axes("right", size="5%", pad="2%") + if colorbar: + ax_divider = make_axes_locatable(ax) + cax = ax_divider.append_axes("right", size="5%", pad="2%") + fig.colorbar(im, ax=ax, cax=cax) - fig.colorbar(im, ax=ax, cax=cax) return fig, ax -- GitLab