I want to use scatter plot and instead of ploting dots on plot, I want to plot images.
I'm doing something like:
import matplotlib.pyplot as plt
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
def getImage(path):
return OffsetImage(plt.imread(path))
paths = get_img_list()
x = mUMAP[0]
y = mUMAP[1]
fig, ax = plt.subplots(figsize=(16, 8), dpi=80)
ax.scatter(x, y)
for x0, y0, path in zip(x, y,paths):
ab = AnnotationBbox(getImage(path), (x0, y0), frameon=False, fontsize=2)
ax.add_artist(ab)
The images are too big.
- How can I control the size of the image box ?
- How can I display smaller images ?
CodePudding user response:
You can set the zoom
argument from OffsetImage
to a value of your liking.
Below are two examples:
With OffsetImage(plt.imread(path),zoom=0.8)
:
And with: