title: Automatically find and add the coordinates to add Annotations (e.g. count) on a Boxplot made from a Dictionary of uneven Lists
body: <p>I'm pretty new in programming world and I'm really frustrated to solve a problem which I thought should be really easy...</p>
  <p>Case: Let's say I have a Dictionary with uneven Lists; Also the number of Keys(string) &amp; Values(number) could change anytime.</p>
  <p>Need: I want to annotate (add text or whatever) some Information (e.g. count) to each Subplots or Categories (each Key is an individual Category).</p>
  <p>Problem: I found many solutions for evenly numbered Categories, which apparently doesn't work for me. <a href="https://stackoverflow.com/questions/69881191/adding-counts-to-plotly-boxplots">e.g. Solution</a></p>
  <p>I also found some Answers <a href="https://stackoverflow.com/questions/27913674/matplotlib-get-axis-relative-tick-positions">e.g. Solution</a> , that I should first get the Coordinates of each Keys in the x-line and then do a inverted transformation to work with the &quot;log scales&quot;. Which was so far the best solution for me, but unfortunately it does not really fit the Coordinates and I couldn't get &amp; add the points automatically before using plt.show().</p>
  <p>I could also guess the coordinates with trial error in the Transformation Method or with Offset <a href="https://stackoverflow.com/questions/68965009/add-image-annotations-to-boxplot">e.g. Solution</a>. But as I said, my Dictionary could change anytime, and then I should do it again every time!</p>
  <p>I think there should be much more simpler method to solve this problem, but I couldn't find it.</p>
  <p>Here is the simplified example of my Code and what I tried:</p>
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from matplotlib.offsetbox import (TextArea, DrawingArea, OffsetImage,
                                    AnnotationBbox)
  
  dictionary = {}
  dictionary[&quot;a&quot;] = [1, 2, 3, 4, 5]
  dictionary[&quot;b&quot;] = [1, 2, 3, 4, 5, 6, 7]
  
  fig, ax = plt.subplots()
  ax.boxplot(dictionary.values())
  x = ax.set_xticklabels(dictionary.keys())
  
  fig.text(x = 0.25, y = 0, s = str(len(dictionary[&quot;a&quot;])))
  fig.text(x = 0.75, y = 0, s = str(len(dictionary[&quot;b&quot;])))
  
  
  plt.show()
  
  
  crd = np.vstack((ax.get_xticks(), np.zeros_like(ax.get_xticks()))).T
  ticks = ax.transAxes.inverted().transform(ax.transData.transform(crd))
  
  print(ticks[:,0])
  
  
  
  # ab = AnnotationBbox(TextArea(&quot;text&quot;), xy=(1, 0), xybox =(0, -30), boxcoords=&quot;offset points&quot;,pad=0,frameon=False )
  # ax.add_artist(ab)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/KaT71.png" rel="nofollow noreferrer">Output of my code</a></p>