看板 Mathematica 關於我們 聯絡資訊
前幾天我遇到的問題是怎樣把一堆極座標的資料點, 換成直角坐標 polartest = Table[{10 Random[], 2 Pi Random[]}, {i, 1, 10}] 首先我用這個建立了10個 r,theta格式的資料點 p2x = CoordinateTransformData["Polar" -> "Cartesian", "Mapping"] 這是個Mathematica的內建座標轉換函數,"Polar"也可以是"Spherical" 其實也等價於{Cos[#1[[2]]] #1[[1]], Sin[#1[[2]]] #1[[1]]} & carttest = p2x /@ polartest xtick = Table[i, {i, -10, 10, 2}]; ytick = xtick; ListPolarPlot[Reverse /@ polartest, Ticks -> {xtick, ytick}, PlotRange -> All, PlotLabel -> "PolarCoordinate"] 我在這邊始終沒有得到正確的結果是因為,ListPolarPlot吃的是theta,r的list 因此必須在這裡使用Reverse把list裡面的兩個函數反過來 ListPlot[carttest, Ticks -> {xtick, ytick}, PlotRange -> All, PlotLabel -> "XY Coordinate", AspectRatio -> 1] 再用ListPlot畫出來就可以看到這個轉換是成功的了 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.166.241.220 ※ 文章網址: http://www.ptt.cc/bbs/Mathematica/M.1416157489.A.A43.html
chungyuandye: 偷懶的作法: ListPolarPlot[data][[1, 3, 2, 1]] 11/17 08:25
ntust661: 推~ 11/20 18:55