function h = polarbubblechart(varargin)
%POLARBUBBLECHART Polar bubble chart.
%   POLARBUBBLECHART(theta,r,sz) displays circular markers (bubbles) at the 
%   locations specified by the vectors th and r in polar coordinates. 
%   Specify the size of the bubbles as the vector sz. The vectors theta, r, 
%   and sz must be the same size. 
%
%   POLARBUBBLECHART(theta,r,sz,c) sets the marker colors using c. When c
%   is a vector the same length as theta and r, the values in c are
%   linearly mapped to the colors in the current colormap. When c is a
%   length(theta)-by-3 matrix, it specifies the colors of the markers as
%   RGB triplet values. c can also be a character vector containing a color
%   name, such as 'red'.
%
%   POLARBUBBLECHART(tbl,thetavar,rvar,szvar) creates a bubble chart with
%   the variables thetavar, rvar, and szvar from table tbl. Multiple bubble
%   charts are created if rvar, thetavar, or szvar reference multiple
%   variables. For example, this command creates two bubble charts:
%   polarbubblechart(tbl, 'var1', {'var2', 'var3'}, 'var4')
%
%   POLARBUBBLECHART(tbl,thetavar,rvar,szvar,colorvar) specifies the color
%   of the bubble charts with the table variable colorvar.
%
%   POLARBUBBLECHART(...,Name,Value) sets bubble chart properties using one
%   or more name-value pair arguments. For example:
%   POLARBUBBLECHART(theta,r,sz,'MarkerEdgeColor','k') uses a black outline 
%   for the markers.
%
%   POLARBUBBLECHART(ax,...) specifies the target axes instead of the 
%   current axes.
%
%   bc = POLARBUBBLECHART(...) returns the BubbleChart object. Use bc to 
%   set properties on the chart after creating it.
%
%   Example:      
%     th = 0:.2:2*pi; 
%     r = cos(th).^2;
%     sz = sin(th);
%     polarbubblechart(th,r,sz);
%
%   See also BUBBLELIM, BUBBLESIZE, BUBBLELEGEND, BUBBLECHART, BUBBLECHART3
%   POLARSCATTER, RLIM, POLARAXES

%   Copyright 2020-2021 The MathWorks, Inc.

narginchk(1,inf)
[cax, args] = axescheck(varargin{:});
if ~isempty(cax) && ~isa(cax, 'matlab.graphics.axis.PolarAxes')
    error(message('MATLAB:polarplot:AxesInput'));
end
try
    cax = matlab.graphics.internal.prepareCoordinateSystem('polar', cax);   

    obj = bubblechart(cax, args{:});
catch e
    switch e.identifier
        case 'MATLAB:bubble:InvalidData'
            error(message(e.identifier, 'Theta', 'rho'));
        case 'MATLAB:Chart:InvalidTableSubscript'
            if isequal(e.message,getString(message(e.identifier, 'X')))
                e = MException(message(e.identifier, 'Theta'));
            elseif isequal(e.message,getString(message(e.identifier, 'Y')))
                e = MException(message(e.identifier, 'Rho'));
            end
            throw(e)
        otherwise
            throw(e);
    end
end

if nargout > 0
    h = obj;
end

