Skip to content

Commit 16d9a17

Browse files
committed
[FIX] Fixed plot_point_brain() function
Currently, in the plot_point_brain() function, the xyz aspect ratios are manually adjusted to [0.57, 0.57, 0.60]. This manual adjustement provides nice-looking brains that are unfortunately not accurate representations of the actual coordinates of the brain. The way the brain will look will also be totally dependent on the values of the coordinates that we input. This might not be something that we want. I therefore changed the way we adjust the aspect ratio of the different axes such that the ratio is accurately depicting the relationship between the different axes.
1 parent 46fdb31 commit 16d9a17

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

netneurotools/plotting.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,6 @@ def plot_point_brain(data, coords, views=None, cbar=False, figsize=(4, 4.8),
762762
coronal=(0, 90), cor=(0, 90))
763763

764764
# coordinate space needs to be centered around zero for aspect ratio
765-
coords = zscore(coords)
766765
x, y, z = coords[:, 0], coords[:, 1], coords[:, 2]
767766
if views is None:
768767
views = [_views[f] for f in ['sagittal', 'axial']]
@@ -789,10 +788,11 @@ def plot_point_brain(data, coords, views=None, cbar=False, figsize=(4, 4.8),
789788
# make the actual scatterplot and update the view / aspect ratios
790789
col = ax.scatter(x, y, z, c=data, s=size, **opts)
791790
ax.view_init(*view)
792-
ax.axis('off')
793-
ax.set(xlim=0.57 * np.array(ax.get_xlim()),
794-
ylim=0.57 * np.array(ax.get_ylim()),
795-
zlim=0.60 * np.array(ax.get_zlim()))
791+
# ax.axis('off')
792+
scaling = np.array([ax.get_xlim(),
793+
ax.get_ylim(),
794+
ax.get_zlim()])
795+
ax.auto_scale_xyz(*[[np.min(scaling), np.max(scaling)]]*3)
796796
fig.subplots_adjust(left=0, right=1, bottom=0, top=1)
797797

798798
# add colorbar to axes

0 commit comments

Comments
 (0)