def _axes_dimensions(ax):
    """
    Dimensions of axes

    :param ax: axes
    :type ax: Axes3DSubplot or AxesSubplot
    :return: dimensionality of axes, either 2 or 3
    :rtype: int
    """
    classname = ax.__class__.__name__
    base_classes = ax.__class__.__bases__
    if classname in ("Axes3DSubplot", "Animate") or any(base_class.__name__ in ("Axes3DSubplot", "Animate") for base_class in base_classes):
        return 3
    elif classname in ("AxesSubplot", "Animate2"):
        return 2