def _validate_x_values(x_values, x_tick_labels, num_expected_values):
    """Validates the x values provided by the user, making sure they are the
    correct length and are all numbers.
    
    Also validates the number of x-axis tick labels.
    
    Raises a ValueError if these conditions are not met.
    """
    if x_values is not None:
        if len(x_values) != num_expected_values:
            raise ValueError(
                'The number of x values must match the number of data points.')
        try:
            map(float, x_values)
        except:
            raise ValueError('Each x value must be a number.')
    if x_tick_labels is not None:
        if len(x_tick_labels) != num_expected_values:
            raise ValueError(
                'The number of x-axis tick labels must match the number of data points.'
                )
