Are there any statistics to see if a categorical variable produces good segments within a scatter plot? Within a scatterplot of two continuous variables. I am looking for a statistical method to determine if a 3rd variable that has a limited number of categories/groups (3-8) is able to produce visually well-defined segments within the original scatter plot.
The following scatterplot would be a example of a good segmentation:

It is clear from this scatter plot that the different scatters are well grouped and are distinct from the other.
Compare that with this one:

This one doesn't have any distinct groups. It may be true that there is some significant correlation/association for all three, i.e., the greater the population, the greater the area, but there are no clear "segments" here.
Initially I have had the idea of measuring the average distance from centroid, and calculate the percentage of dots of a group that are not intersecting with other groups excluding outliers (e.g. IQR method). This could work, but how would I get statistics from it that would signify a good vs bad segmentation? And before I reinvent the wheel, I wanted to check if there are any known/used statistics already.
Or perhaps a test for unimodality of the residuals (dip test)? If it is not unimodal I could try to get the modes? Anyhow, any pointers to robust methods appreciated.
Addendum: I've applied Christian's Hennig's answer using a Calinski-Harabasz Index to dervive the stats. For reference, I published the results here (PDF). The plots are ordered by p values with the Null Hypothesis of independence. p<0.05 indicates a stronger evidence of visual well defined k clusters, which can be nicely seen within the plots.

In cluster analysis, the Silhouette coefficient (SC; or Average Silhouette Width) is a distance-based statistic that measures the quality of a clustering, i.e., to what extent the objects are closer to other objects in the same class than to the closest class to which they don't belong.
This can also be computed for situations as yours in which there is a given grouping; for these data probably the Euclidean distance makes sense.
One qualification is that clusterings found by a cluster analysis method (for with the Silhouette was originally meant) tend to be better separated than data from underlying groupings that have a fairly large variation. Therefore I'd recommend to contrast the SC obtained for your categories (which may look disappointingly low for people who know typical values in cluster analysis) with a permutation test approach, i.e., simulate 1000 (say) data sets where you randomly reshuffle the group labels, compute the SC for all of these, and have a look to what extent (measured in terms of standard deviations of the permutation results, say) the SC in your data is "significantly" larger.
The webpage also mentions a Simplified Silhouette that comes with less computational effort.
Sleeping over this, I realised that I should also mention another classical cluster validity index, the Calinski-Harabasz index (CH), In R here. It can once more be calibrated (or a statistical test be run) using the permutation principle. More than the SC, this is based on the standard statistics characterising the Gaussian distribution, namely mean vector and sums of squares, so will be appropriate for within-group distributions that are not too far from the Gaussian. It is based on (multivariate) Analysis of Variance logic.  In fact, as @Stephan Kolassa correctly noted, both the SC and the CH will reward classes with large within-class homogeneity, whereas (potentially nonlinear) classes with larger within-class variation may not be assessed as good.
