code: def plot_covariance(
      mean,
      cov=None,
      variance=1.0,
      std=None,
      interval=None,
      ellipse=None,
      title=None,
      axis_equal=True,
      show_semiaxis=False,
      show_center=True,
      facecolor=None,
      edgecolor=None,
      fc="none",
      ec="#004080",
      alpha=1.0,
      xlim=None,
      ylim=None,
      ls="solid",
  ):
      """
      Plots the covariance ellipse for the 2D normal defined by (mean, cov)
  
      `variance` is the normal sigma^2 that we want to plot. If list-like,
      ellipses for all ellipses will be ploted. E.g. [1,2] will plot the
      sigma^2 = 1 and sigma^2 = 2 ellipses. Alternatively, use std for the
      standard deviation, in which case `variance` will be ignored.
  
      ellipse is a (angle,width,height) tuple containing the angle in radians,
      and width and height radii.
  
      You may provide either cov or ellipse, but not both.
  
      Parameters
      ----------
  
      mean : row vector like (2x1)
          The mean of the normal
  
      cov : ndarray-like
          2x2 covariance matrix
  
      variance : float, default 1, or iterable float, optional
          Variance of the plotted ellipse. May specify std or interval instead.
          If iterable, such as (1, 2**2, 3**2), then ellipses will be drawn
          for all in the list.
  
  
      std : float, or iterable float, optional
          Standard deviation of the plotted ellipse. If specified, variance
          is ignored, and interval must be `None`.
  
          If iterable, such as (1, 2, 3), then ellipses will be drawn
          for all in the list.
  
      interval : float range [0,1), or iterable float, optional
          Confidence interval for the plotted ellipse. For example, .68 (for
          68%) gives roughly 1 standand deviation. If specified, variance
          is ignored and `std` must be `None`
  
          If iterable, such as (.68, .95), then ellipses will be drawn
          for all in the list.
  
  
      ellipse: (float, float, float)
          Instead of a covariance, plots an ellipse described by (angle, width,
          height), where angle is in radians, and the width and height are the
          minor and major sub-axis radii. `cov` must be `None`.
  
      title: str, optional
          title for the plot
  
      axis_equal: bool, default=True
          Use the same scale for the x-axis and y-axis to ensure the aspect
          ratio is correct.
  
      show_semiaxis: bool, default=False
          Draw the semiaxis of the ellipse
  
      show_center: bool, default=True
          Mark the center of the ellipse with a cross
  
      facecolor, fc: color, default=None
          If specified, fills the ellipse with the specified color. `fc` is an
          allowed abbreviation
  
      edgecolor, ec: color, default=None
          If specified, overrides the default color sequence for the edge color
          of the ellipse. `ec` is an allowed abbreviation
  
      alpha: float range [0,1], default=1.
          alpha value for the ellipse
  
      xlim: float or (float,float), default=None
         specifies the limits for the x-axis
  
      ylim: float or (float,float), default=None
         specifies the limits for the y-axis
  
      ls: str, default='solid':
          line style for the edge of the ellipse
      """
  
      from matplotlib.patches import Ellipse
      import matplotlib.pyplot as plt
  
      if cov is not None and ellipse is not None:
          raise ValueError("You cannot specify both cov and ellipse")
  
      if cov is None and ellipse is None:
          raise ValueError("Specify one of cov or ellipse")
  
      if facecolor is None:
          facecolor = fc
  
      if edgecolor is None:
          edgecolor = ec
  
      if cov is not None:
          ellipse = covariance_ellipse(cov)
  
      if axis_equal:
          plt.axis("equal")
  
      if title is not None:
          plt.title(title)
  
      ax = plt.gca()
  
      angle = np.degrees(ellipse[0])
      width = ellipse[1] * 2.0
      height = ellipse[2] * 2.0
  
      std = _std_tuple_of(variance, std, interval)
      for sd in std:
          e = Ellipse(
              xy=mean,
              width=sd * width,
              height=sd * height,
              angle=angle,
              facecolor=facecolor,
              edgecolor=edgecolor,
              alpha=alpha,
              lw=2,
              ls=ls,
          )
          ax.add_patch(e)
      x, y = mean
      if show_center:
          plt.scatter(x, y, marker="+", color=edgecolor)
  
      if xlim is not None:
          ax.set_xlim(xlim)
  
      if ylim is not None:
          ax.set_ylim(ylim)
  
      if show_semiaxis:
          a = ellipse[0]
          h, w = height / 4, width / 4
          plt.plot(
              [x, x + h * cos(a + np.pi / 2)],
              [y, y + h * sin(a + np.pi / 2)],
          )
          plt.plot([x, x + w * cos(a)], [y, y + w * sin(a)])
  
imports: from __future__ import absolute_import, division, unicode_literals
  import math
  from math import cos, sin
  import random
  import warnings
  import numpy
  from numpy.linalg import inv
  import scipy.linalg
  import scipy.sparse
  import scipy.sparse.linalg
  from scipy.stats import norm, multivariate_normal
label_desc: Use image node_id 21 for calling a global function with example usage: plot_covariance(mean, cov, variance, std, interval, ellipse, title, axis_equal, show_semiaxis, show_center, facecolor, edgecolor, fc, ec, alpha, xlim, ylim, ls) without return types