0

I'm writing a script to classify images based on their features: Histogram, color balance, keypoint count, etc. And although the function that I wrote to display the charts works fine:

fig,axes = plt.subplots(2,3,figsize=(15,7))

axes[0, 0].scatter((zip(*xy_a))[0], (zip(*xy_a))[1])
for i, txt in enumerate(xy_na): axes[0, 0].annotate(txt, ((zip(*xy_a))[0][i],(zip(*xy_a))[1][i]))
axes[0, 0].set_title("xy_a")
axes[0, 0].set_xlabel('Histogram')
axes[0, 0].set_ylabel('Average Pixel')

axes[1, 0].scatter(*zip(*xy_b))
for i, txt in enumerate(xy_na): axes[1, 0].annotate(txt, ((zip(*xy_b))[0][i],(zip(*xy_b))[1][i]))
axes[1, 0].set_title("xy_b")
axes[1, 0].set_xlabel('Average Pixel')
axes[1, 0].set_ylabel('Keypoint Number')

axes[0, 1].scatter(*zip(*xy_c))
for i, txt in enumerate(xy_na): axes[0, 1].annotate(txt, ((zip(*xy_c))[0][i],(zip(*xy_c))[1][i]))
axes[0, 1].set_title("xy_c")
axes[0, 1].set_xlabel('Keypoint Number')
axes[0, 1].set_ylabel('Histogram')

axes[1, 1].scatter(*zip(*xy_d))
for i, txt in enumerate(xy_na): axes[1, 1].annotate(txt, ((zip(*xy_d))[0][i],(zip(*xy_d))[1][i]))
axes[1, 1].set_title("xy_d")
axes[1, 1].set_xlabel('Dimentional Mean')
axes[1, 1].set_ylabel('Histogram')

axes[0, 2].scatter(*zip(*xy_e))
for i, txt in enumerate(xy_na): axes[0, 2].annotate(txt, ((zip(*xy_e))[0][i],(zip(*xy_f))[1][i]))
axes[0, 2].set_title("xy_e")
axes[0, 2].set_xlabel('Average Pixel')
axes[0, 2].set_ylabel('Dimentional Mean')

axes[1, 2].scatter(*zip(*xy_f))
for i, txt in enumerate(xy_na): axes[1, 2].annotate(txt, ((zip(*xy_f))[0][i],(zip(*xy_f))[1][i]))
axes[1, 2].set_title("xy_f")
axes[1, 2].set_xlabel('Keypoint Number')
axes[1, 2].set_ylabel('Dimentional Mean')

fig.tight_layout()
fig.suptitle("Folder: {}".format ((str(folder_path)).split("/")[-1]))

plt.show()

The chart that it generates is less than readable:

enter image description here

That folder has 13 images in it: 11 facial shots and 2 group pictures. Now, it's not entirely unreadable, but what happens when I run it on a folder with 100 images?

There are other answers on overlapping annotations, but none of them are applicable to my one-liner annotation scheme. If anyone could find a solution to my problem, that would be great.

Rich
  • 1,103
  • 1
  • 15
  • 36
  • Maybe you need to physically separate the points. Here is the logic I would use: sort on x and y points, if x_prev_pt - x_current_pt <= 1.5*text_pt_size, then shift the annotations x by the difference, similarly for y. I know how to do this in pandas, but unfortunately I am not able to glean your the structure of your data... – Kartik Aug 17 '16 at 05:12
  • They're all just lists: `xy_a = [], xy_b = [], xy_c = [], xy_d = [], xy_e = [], xy_f = [], xy_na = []` – Rich Aug 17 '16 at 05:17

1 Answers1

1

I would suggest that, instead of showing all annotations at all time, just show the annotation when you click on a data point. The same data point could also be highlighted in the other subplots.

See this cookbook recipe for an example on how to achieve this

Diziet Asahi
  • 38,379
  • 7
  • 60
  • 75