在極坐標中繪圖
以下示例演示如何在極坐標中創建線圖、散點圖和直方圖。此外,還演示了如何對極坐標圖添加注釋和更改軸范圍。
創建極坐標線圖
通過極坐標中的天線以可視方式呈現輻射圖。加載文件 antennaData.mat,該文件包含變量 theta 和 rho。變量 rho 用於測量天線對 theta 的每個值的輻射強度。通過使用 polarplot 函數在極坐標中繪制數據圖來對該輻射圖進行可視化。
load(fullfile(matlabroot,'examples','matlab_featured','antennaData.mat')) figure polarplot(theta,rho)

多個極坐標線圖
使用 hold on 保留當前極坐標區,然后通過 polarplot 繪制其他數據圖。
rng('default')
noisy = rho + rand(size(rho));
hold on
polarplot(theta,noisy)
hold off

為極坐標圖添加注釋
使用 legend 和 title 之類的注釋函數標記與其他可視化類型類似的極坐標圖。
legend('Original','With Noise')
title('Antenna Radiation Pattern')

更改極坐標區范圍
默認情況下,在極坐標圖中,半徑的負值將被繪制為正值。使用 rlim 將 r 坐標軸范圍調整為包含負值。
rmin = min(rho); rmax = max(rho); rlim([rmin rmax])

使用 thetalim 將 theta 坐標軸范圍更改為 0 和 180。
thetalim([0 180])

創建極坐標散點圖
在極坐標中繪制風速數據圖。加載文件 windData.dat,該文件包含變量 direction、speed、humidity 和 C。通過使用 polarscatter 函數在極坐標中繪制數據圖來以可視方式呈現風速圖。
load(fullfile(matlabroot,'examples','matlab_featured','windData.mat')) polarscatter(direction,speed)

包括第三個數據輸入以改變標記大小並表示第三個維度。
polarscatter(direction,speed,humidity)

使用格式化輸入調整標記顯示屬性。
polarscatter(direction,speed,humidity,C,'filled')

創建極坐標直方圖
使用 polarhistogram 函數以可視方式呈現數據,這將會生成稱為風向圖的可視表示形式。
polarhistogram(direction)

指定 bin 確定算法。polarhistogram 函數具有各種確定 bin 數量和 bin 寬度的算法,可從 BinMethod 字段中選擇。
polarhistogram(direction,'BinMethod','sqrt')

指定 bin 數量和 bin 寬度。
polarhistogram(direction,24,'BinWidth',.5)

指定歸一化方法並調整顯示樣式以排除任何填充。
polarhistogram(direction,'Normalization','pdf','DisplayStyle','stairs')

