function out=violinPlot(data,color,figHandle)

bufferWidth=0.2;
numPts=100;
violinColor=color;

switch class(data)
    case 'double'
        numVectors=size(data,2);
        dataTemp={};
        for i=1:numVectors
            dataTemp=[dataTemp data(:,i)]; 
        end
        data=dataTemp;
    case 'cell'
        numVectors=length(data);
end

figure(figHandle);
hold on;

fs=zeros(numPts,numVectors);
xis=zeros(numPts,numVectors);
fs2=zeros(numPts+2,numVectors);
xis2=zeros(numPts+2,numVectors);

for i=1:numVectors
    [fs(:,i),xis(:,i)] = ksdensity(data{i});
    
    xis2(:,i)=sort([xis(:,i);0;1]);
    fs2(:,i)=interp1(xis(:,i),fs(:,i),xis2(:,i),'spline',0);
end

fs=fs/(max(max(fs))*(2+bufferWidth));

for i=1:numVectors
    h=fill([i-fs(:,i)' i+fliplr(fs(:,i)')],[xis(:,i)' fliplr(xis(:,i)')],violinColor,'HandleVisibility','off');
    h.EdgeColor='none';
end

out.xis=xis;
out.fs=fs;