How can I test if there are significant differences between four distributions? Here is a graphical display of my data:

The x-axis is categorical from 0-5 in terms of how many of a certain damage type are present on a leaf (with pink and blue bars representing the different types). The y-axis is how many leaves (out of 100 sampled) on that tree have that type of damage. I am interested in seeing whether there is a significant difference between the distributions within each tree (e.g. Tree 1 pink vs. Tree 1 blue distribution), and whether there are differences between the trees (e.g. Tree 1 pink vs. Tree 2 pink). Is there a statistical test to do that? I was thinking chi-squared but I feel as though it is not appropriate because some frequencies are zero.
 A: Yes, chi-square. I had a similar problem lately, and perhaps you may use my solution. I believe that for the purpose of chi-square test, prior to computing the chi-square statistics you are permitted to aggregate the categories with low expected count into one category named "other". Then you are good to go, because you will have very few cells with low frequencies, so you meet the chi2 condition of 80% high-frequency cells.
Below is my Python implementation if you are interested. Note it implements the chi-square test for independence to compare two variables (while you need the chi-square goodness of fit to compare two populations, which is slightly different) but I believe you could directly use my code with the following approach.
If you introduce a variable (column) "tree" so that each record (leaf) would have the tree number associated to it (it might be that you already have such variable) then this becomes your target (dependent) variable, against which the independent variable "damage type" can be tested.
Then the problem you described can be reduced to the chi2 test for independence between these two variables. In the result you will see if the distribution of the variable "damage type" is dependent of the tree specimen or not.
The implementation is here (look at the usage file), and here is an intro article about it.
I would also welcome critics or improvements to the approach I propose.
