Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new argument, cmap, to the plotting function. #237

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions feat/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def draw_vectorfield(
return ax


def draw_muscles(currx, curry, au=None, ax=None, *args, **kwargs):
def draw_muscles(currx, curry, au=None, ax=None, cmap="Blues", *args, **kwargs):
"""Draw Muscles

Args:
Expand Down Expand Up @@ -756,7 +756,7 @@ def draw_muscles(currx, curry, au=None, ax=None, *args, **kwargs):
del kwargs[muscle]
for muscle in todraw.keys():
if todraw[muscle] == "heatmap":
muscles[muscle].set_color(get_heat(muscle, au, facet))
muscles[muscle].set_color(get_heat(muscle, au, facet, cmap))
else:
muscles[muscle].set_color(todraw[muscle])
ax.add_patch(muscles[muscle], *args, **kwargs)
Expand Down Expand Up @@ -805,7 +805,7 @@ def draw_muscles(currx, curry, au=None, ax=None, *args, **kwargs):
return ax


def get_heat(muscle, au, log):
def get_heat(muscle, au, log, cmap="Blues"):
"""Function to create heatmap from au vector

Args:
Expand All @@ -817,7 +817,7 @@ def get_heat(muscle, au, log):
Returns:
color of muscle according to its au value
"""
q = sns.color_palette("Blues", 151)
q = sns.color_palette(cmap, 151)
unit = 0
aus = {
"masseter_l": 15,
Expand Down Expand Up @@ -882,6 +882,7 @@ def plot_face(
muscles=None,
ax=None,
feature_range=False,
cmap="Blues",
color="k",
linewidth=1,
linestyle="-",
Expand Down Expand Up @@ -937,7 +938,7 @@ def plot_face(
au = minmax_scale(au, feature_range=(0, 100 * muscle_scaler))
else:
au = muscle_scaler.transform(np.array(au).reshape(-1, 1)).squeeze()
ax = draw_muscles(currx, curry, ax=ax, au=au, **muscles)
ax = draw_muscles(currx, curry, cmap, ax=ax, au=au, **muscles)

if gaze is not None and len((gaze)) != 4:
warnings.warn(
Expand Down