Skip to content

Commit

Permalink
avoiding double colorbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Skoricius committed May 19, 2024
1 parent 32a2585 commit c5cf961
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions f3ast/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create_3d_axes():
return ax


def points3d(verts, *args, ax=None, equal_axes=True, **kwargs):
def points3d(verts, *args, ax=None, equal_axes=True, colorbar: bool = True, **kwargs):
"""Plots the 3D points in a 3D scatter plot.
Args:
Expand All @@ -32,7 +32,8 @@ def points3d(verts, *args, ax=None, equal_axes=True, **kwargs):
sc = ax.scatter(verts[:, 0], verts[:, 1], verts[:, 2], *args, **kwargs)
if equal_axes:
set_axes_equal(ax)
plt.colorbar(sc, shrink=0.8)
if colorbar:
plt.colorbar(sc, shrink=0.8)
return ax, sc


Expand All @@ -45,7 +46,8 @@ def plot_dwells(dwells):
Returns:
tuple: axes, scatter_plot
"""
ax, sc = points3d(dwells[:, 1:], c=dwells[:, 0], cmap="magma")
ax, sc = points3d(dwells[:, 1:], c=dwells[:, 0],
cmap="magma", colorbar=False)
plt.colorbar(sc, ax=ax, shrink=0.6, label="t [ms]")
set_axes_equal(ax)
return ax, sc
Expand Down

0 comments on commit c5cf961

Please sign in to comment.