Skip to content

Commit

Permalink
Merge pull request #1123 from 36000/plotly_quick_change
Browse files Browse the repository at this point in the history
[ENH] small change to viz utils panel code
  • Loading branch information
36000 authored Apr 22, 2024
2 parents a2aa28b + d83da24 commit 57b397a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions AFQ/viz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def __init__(self, num_rows, num_cols, width, height,

def add_img(self, fname, x_coord, y_coord, reduct_count=1,
subplot_label_pos=(0.1, 1.0), legend=None, legend_kwargs={},
add_panel_label=True):
add_panel_label=True, panel_label_kwargs={}):
"""
Add image from fname into figure as a panel.
Expand All @@ -214,6 +214,9 @@ def add_img(self, fname, x_coord, y_coord, reduct_count=1,
add_panel_label : bool
Whether or not to add a panel label to the subplot
Default: True
panel_label_kwargs : dict
Additional arguments for matplotlib's text method,
which is used to add panel labels to each subplot.
"""
ax = self.fig.add_subplot(self.grid[y_coord, x_coord])
im1 = Image.open(fname)
Expand All @@ -229,11 +232,13 @@ def add_img(self, fname, x_coord, y_coord, reduct_count=1,
if add_panel_label:
trans = mtransforms.ScaledTranslation(
10 / 72, -5 / 72, self.fig.dpi_scale_trans)
this_pl_kwargs = self.panel_label_kwargs.copy()
this_pl_kwargs.update(panel_label_kwargs)
ax.text(
subplot_label_pos[0], subplot_label_pos[1],
f"{chr(65+self.subplot_count)}",
transform=ax.transAxes + trans,
**self.panel_label_kwargs)
**this_pl_kwargs)
ax.imshow(np.asarray(im1), aspect=1)
ax.axis('off')
self.subplot_count = self.subplot_count + 1
Expand Down

0 comments on commit 57b397a

Please sign in to comment.