From 0fbc482c10b11f7b72e7330255759a433a493185 Mon Sep 17 00:00:00 2001 From: Mattijn van Hoek Date: Fri, 20 Oct 2023 09:38:51 +0200 Subject: [PATCH 1/2] Update numpy-tooltip-images.rst --- doc/case_studies/numpy-tooltip-images.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/case_studies/numpy-tooltip-images.rst b/doc/case_studies/numpy-tooltip-images.rst index 786a4c8e8..de581858e 100644 --- a/doc/case_studies/numpy-tooltip-images.rst +++ b/doc/case_studies/numpy-tooltip-images.rst @@ -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 @@ -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']) @@ -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']) From 07e723ad753a44096ed1c16729303d9fbd1d3a87 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sat, 16 Mar 2024 09:28:44 -0700 Subject: [PATCH 2/2] Clarify intro --- doc/case_studies/numpy-tooltip-images.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/case_studies/numpy-tooltip-images.rst b/doc/case_studies/numpy-tooltip-images.rst index de581858e..ee04eb3b6 100644 --- a/doc/case_studies/numpy-tooltip-images.rst +++ b/doc/case_studies/numpy-tooltip-images.rst @@ -8,9 +8,11 @@ you’ll learn how to display images stored as Numpy arrays in tooltips with any Altair chart. First, -we create some example image arrays with blobs of different sizes. +we create some example image arrays with blobs (objects) +of different sizes and shapes (circular and square). We measure the area of the blobs -in order to have a quantitative measurement to plot. +in order to have a quantitative measurement +to compare them with in our charts. .. altair-plot:: :output: repr