Skip to content

Commit

Permalink
Update numpy-tooltip-images.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
mattijn authored Oct 20, 2023
1 parent cf76f03 commit 0fbc482
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/case_studies/numpy-tooltip-images.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ in order to have a quantitative measurement to plot.
'group': rng.choice(['a', 'b', 'c'], size=n_rows)
})
# Compute the area as the proportion of pixels above a threshold
df[['image1_area', 'image2_area']] = df[['image1', 'image2']].applymap(lambda x: (x > 0.4).mean())
df[['image1_area', 'image2_area']] = df[['image1', 'image2']].map(lambda x: (x > 0.4).mean())
df

Next, we define the function
Expand Down Expand Up @@ -87,7 +87,7 @@ is in the form of an image and render it appropriately.
return f"data:image/png;base64,{img_str}"

# The column with the base64 image string must be called "image" in order for it to trigger the image rendering in the tooltip
df['image'] = df[['image1', 'image2']].apply(create_tooltip_image, axis=1)
df['image'] = df[['image1', 'image2']].map(create_tooltip_image, axis=1)

# Dropping the image arrays since they are large an no longer needed
df_plot = df.drop(columns=['image1', 'image2'])
Expand Down Expand Up @@ -150,7 +150,7 @@ instead of both the images concatenated together.
return f"data:image/png;base64,{img_str}"

# The column with the base64 image string must be called "image" in order for it to trigger the image rendering in the tooltip
df[['image1_base64', 'image2_base64']] = df[['image1', 'image2']].applymap(create_tooltip_image)
df[['image1_base64', 'image2_base64']] = df[['image1', 'image2']].map(create_tooltip_image)
# Dropping the image arrays since they are large an no longer needed
# Also drop the previous tooltip image for clarity
df_plot = df.drop(columns=['image1', 'image2', 'image'])
Expand Down

0 comments on commit 0fbc482

Please sign in to comment.