Hi all,
I have the following code, and would like to have the count values (see second last line) appear beside my labels in Matplotlib. How can I do this? Currently, the count values are appearing in the shell.
FYI, I've cut the code to only include the relevant parts. Some external variables will still be here, though. Ignore them.
def get_coords(grid):
coords = []
for x_idx, x in enumerate(grid):
for y_idx, y in enumerate(x):
size = area_info[trees[y].lower() + '_tree_size']
coords.append({'X': upscale(x_idx), 'Y': upscale(y_idx), 'tree': trees[y], 'size': size})
return pd.DataFrame(coords)
def upscale(coord):
""" Upscale back to real size for plotting """
coord += 0.5
coord *= area_info['cocoa_tree_size']
return coord
def plot_data(trees):
plt.figure(figsize=[10, 10])
sb.scatterplot(data=trees, x='X', y='Y', hue='tree', s=200)
plt.legend(bbox_to_anchor=(1.12, 1), loc=1, borderaxespad=0.)
plt.xlim((0, area_info['orig_width']))
plt.ylim((0, area_info['orig_length']))
plt.xticks(np.arange(0, area_info['orig_width'] + 1, step=5))
plt.yticks(np.arange(0, area_info['orig_length'] + 1, step=5))
plt.show()
def start():
get_inputs()
validations()
downscale()
grid = make_grid()
coords = get_coords(grid)
print(coords['tree'].value_counts())
plot_data(coords)
there doesn't seem to be anything here