{"id":986540,"date":"2024-12-27T07:45:54","date_gmt":"2024-12-26T23:45:54","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/986540.html"},"modified":"2024-12-27T07:45:57","modified_gmt":"2024-12-26T23:45:57","slug":"python%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e5%ae%9a%e4%b9%89%e6%8a%95%e5%bd%b1","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/986540.html","title":{"rendered":"python\u5982\u4f55\u5b9e\u73b0\u5b9a\u4e49\u6295\u5f71"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25063100\/79a599f5-b9f9-45e9-b986-013a069fcf3a.webp\" alt=\"python\u5982\u4f55\u5b9e\u73b0\u5b9a\u4e49\u6295\u5f71\" \/><\/p>\n<p><p> \u4e00\u3001\u901a\u8fc7\u4f7f\u7528Python\u5e93\u5b9e\u73b0\u6295\u5f71\u3001\u5229\u7528NumPy\u8fdb\u884c\u77e9\u9635\u8fd0\u7b97\u3001\u4f7f\u7528Pyproj\u5e93\u8fdb\u884c\u5750\u6807\u8f6c\u6362<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c<strong>\u5b9e\u73b0\u6295\u5f71\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528Python\u5e93\u6765\u8fdb\u884c\uff0c\u5982\u5229\u7528NumPy\u8fdb\u884c\u77e9\u9635\u8fd0\u7b97\u3001\u4f7f\u7528Pyproj\u5e93\u8fdb\u884c\u5750\u6807\u8f6c\u6362\u7b49<\/strong>\u3002\u5176\u4e2d\uff0cPyproj\u5e93\u662f\u4e00\u4e2a\u7528\u4e8e\u5730\u7406\u5750\u6807\u8f6c\u6362\u7684Python\u5e93\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u8f7b\u677e\u5730\u5728\u4e0d\u540c\u7684\u5730\u7406\u5750\u6807\u7cfb\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\u3002\u901a\u8fc7\u4f7f\u7528Pyproj\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9a\u4e49\u5e76\u5e94\u7528\u5404\u79cd\u6295\u5f71\uff0c\u4ece\u800c\u5b9e\u73b0\u5750\u6807\u7684\u8f6c\u6362\u4e0e\u53d8\u6362\u3002\u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Pyproj\u5e93\u6765\u5b9e\u73b0\u6295\u5f71\u3002<\/p>\n<\/p>\n<p><p>Pyproj\u5e93\u662f\u57fa\u4e8ePROJ\u5e93\u7684Python\u63a5\u53e3\uff0c\u80fd\u591f\u8fdb\u884c\u6295\u5f71\u5750\u6807\u548c\u5730\u7406\u5750\u6807\u4e4b\u95f4\u7684\u8f6c\u6362\u3002\u9996\u5148\uff0c\u5b89\u88c5Pyproj\u5e93\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>pip install pyproj<\/code>\u6765\u5b9e\u73b0\u3002\u4f7f\u7528Pyproj\u5e93\u5b9a\u4e49\u6295\u5f71\u65f6\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u5b9a\u4e49\u6e90\u5750\u6807\u7cfb\u548c\u76ee\u6807\u5750\u6807\u7cfb\u3002\u901a\u8fc7\u8c03\u7528<code>pyproj.Transformer.from_crs()<\/code>\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u6295\u5f71\u8f6c\u6362\u5668\u3002\u8fd9\u4e2a\u65b9\u6cd5\u9700\u8981\u4e24\u4e2a\u53c2\u6570\uff1a\u6e90\u5750\u6807\u7cfb\u548c\u76ee\u6807\u5750\u6807\u7cfb\u7684CRS\uff08Coordinate Reference System\uff09\u4ee3\u7801\u3002\u63a5\u7740\uff0c\u901a\u8fc7\u8c03\u7528\u8f6c\u6362\u5668\u7684<code>transform()<\/code>\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5750\u6807\u4ece\u6e90\u5750\u6807\u7cfb\u8f6c\u6362\u4e3a\u76ee\u6807\u5750\u6807\u7cfb\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001NUMPY\u5e93\u7684\u4f7f\u7528<\/p>\n<\/p>\n<p><p>NumPy\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u503c\u8ba1\u7b97\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u591a\u7ef4\u6570\u7ec4\u5bf9\u8c61\u548c\u591a\u79cd\u8fd0\u7b97\u529f\u80fd\u3002\u5728\u5b9e\u73b0\u6295\u5f71\u65f6\uff0cNumPy\u53ef\u4ee5\u7528\u4e8e\u77e9\u9635\u8fd0\u7b97\u3002\u6295\u5f71\u7684\u672c\u8d28\u662f\u5728\u4e0d\u540c\u7684\u5750\u6807\u7cfb\u4e4b\u95f4\u8fdb\u884c\u7ebf\u6027\u53d8\u6362\uff0c\u8fd9\u53ef\u4ee5\u4f7f\u7528\u77e9\u9635\u8fd0\u7b97\u6765\u5b9e\u73b0\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528NumPy\u5e93\u6765\u8fdb\u884c\u8fd9\u4e9b\u77e9\u9635\u8fd0\u7b97\uff0c\u4ece\u800c\u5b9e\u73b0\u5750\u6807\u53d8\u6362\u3002<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528NumPy\u8fdb\u884c\u6295\u5f71\u8ba1\u7b97\u65f6\uff0c\u6211\u4eec\u9700\u8981\u4e86\u89e3\u6295\u5f71\u77e9\u9635\u7684\u5b9a\u4e49\u3002\u6295\u5f71\u77e9\u9635\u662f\u4e00\u4e2a\u5c06\u4e09\u7ef4\u5750\u6807\u8f6c\u6362\u4e3a\u4e8c\u7ef4\u5750\u6807\u7684\u77e9\u9635\u3002\u901a\u8fc7\u5b9a\u4e49\u4e00\u4e2a\u6295\u5f71\u77e9\u9635\uff0c\u5e76\u4f7f\u7528NumPy\u7684\u77e9\u9635\u4e58\u6cd5\u529f\u80fd\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u4e00\u4e2a\u4e09\u7ef4\u70b9\u6295\u5f71\u5230\u4e8c\u7ef4\u5e73\u9762\u4e0a\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u7b80\u5355\u7684\u6295\u5f71\u8ba1\u7b97\uff0c\u4f8b\u5982\u6b63\u4ea4\u6295\u5f71\u548c\u900f\u89c6\u6295\u5f71\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528PYPROJ\u5e93\u8fdb\u884c\u5750\u6807\u8f6c\u6362<\/p>\n<\/p>\n<p><p>Pyproj\u5e93\u63d0\u4f9b\u4e86\u66f4\u9ad8\u5c42\u6b21\u7684\u5750\u6807\u8f6c\u6362\u529f\u80fd\uff0c\u5b83\u652f\u6301\u591a\u79cd\u5730\u7406\u5750\u6807\u7cfb\u548c\u6295\u5f71\u65b9\u6cd5\u3002\u4f7f\u7528Pyproj\u5e93\u53ef\u4ee5\u8f7b\u677e\u5730\u5728\u4e0d\u540c\u7684\u5730\u7406\u5750\u6807\u7cfb\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\uff0c\u800c\u4e0d\u9700\u8981\u624b\u52a8\u8ba1\u7b97\u6295\u5f71\u77e9\u9635\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5PYPROJ\u5e93<\/strong>\uff1a\u5728\u4f7f\u7528Pyproj\u5e93\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u5b89\u88c5\u5b83\u3002\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>pip install pyproj<\/code>\u6765\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9a\u4e49\u6295\u5f71\u8f6c\u6362\u5668<\/strong>\uff1a\u4f7f\u7528<code>pyproj.Transformer.from_crs()<\/code>\u65b9\u6cd5\u5b9a\u4e49\u6295\u5f71\u8f6c\u6362\u5668\u3002\u8fd9\u4e2a\u65b9\u6cd5\u9700\u8981\u4e24\u4e2a\u53c2\u6570\uff1a\u6e90\u5750\u6807\u7cfb\u548c\u76ee\u6807\u5750\u6807\u7cfb\u7684CRS\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fdb\u884c\u5750\u6807\u8f6c\u6362<\/strong>\uff1a\u4f7f\u7528\u8f6c\u6362\u5668\u7684<code>transform()<\/code>\u65b9\u6cd5\uff0c\u5c06\u4e00\u4e2a\u5750\u6807\u4ece\u6e90\u5750\u6807\u7cfb\u8f6c\u6362\u4e3a\u76ee\u6807\u5750\u6807\u7cfb\u3002\u8fd9\u4e2a\u65b9\u6cd5\u63a5\u6536\u4e09\u4e2a\u53c2\u6570\uff1a\u7ecf\u5ea6\u3001\u7eac\u5ea6\u548c\u9ad8\u5ea6\uff08\u53ef\u9009\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u793a\u4f8b\u4ee3\u7801<\/p>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528Pyproj\u5e93\u8fdb\u884c\u5750\u6807\u8f6c\u6362\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from pyproj import Transformer<\/p>\n<h2><strong>\u5b9a\u4e49\u6e90\u5750\u6807\u7cfb\u548c\u76ee\u6807\u5750\u6807\u7cfb\u7684CRS\u4ee3\u7801<\/strong><\/h2>\n<p>source_crs = &#39;EPSG:4326&#39;  # WGS84\u5750\u6807\u7cfb<\/p>\n<p>target_crs = &#39;EPSG:3857&#39;  # Web\u58a8\u5361\u6258\u6295\u5f71<\/p>\n<h2><strong>\u521b\u5efa\u6295\u5f71\u8f6c\u6362\u5668<\/strong><\/h2>\n<p>transformer = Transformer.from_crs(source_crs, target_crs)<\/p>\n<h2><strong>\u5b9a\u4e49\u5f85\u8f6c\u6362\u7684\u5750\u6807<\/strong><\/h2>\n<p>longitude = 116.3913<\/p>\n<p>latitude = 39.9075<\/p>\n<h2><strong>\u8fdb\u884c\u5750\u6807\u8f6c\u6362<\/strong><\/h2>\n<p>x, y = transformer.transform(latitude, longitude)<\/p>\n<p>print(f&quot;\u8f6c\u6362\u540e\u7684\u5750\u6807\uff1aX={x}, Y={y}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e00\u4e2a\u4f4d\u4e8eWGS84\u5750\u6807\u7cfb\uff08EPSG:4326\uff09\u4e0b\u7684\u5730\u7406\u5750\u6807\u8f6c\u6362\u4e3aWeb\u58a8\u5361\u6258\u6295\u5f71\uff08EPSG:3857\uff09\u4e0b\u7684\u5750\u6807\u3002\u901a\u8fc7\u8c03\u7528<code>transform()<\/code>\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u8f6c\u6362\u540e\u7684\u5750\u6807\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u4f7f\u7528CARTOPY\u5e93\u8fdb\u884c\u5730\u56fe\u7ed8\u5236<\/p>\n<\/p>\n<p><p>Cartopy\u662f\u4e00\u4e2a\u7528\u4e8e\u7ed8\u5236\u5730\u56fe\u7684Python\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5730\u56fe\u6295\u5f71\u548c\u5730\u7406\u6570\u636e\u5904\u7406\u529f\u80fd\u3002\u4f7f\u7528Cartopy\u5e93\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06\u5730\u7406\u6570\u636e\u7ed8\u5236\u5728\u4e0d\u540c\u7684\u5730\u56fe\u6295\u5f71\u4e0a\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5CARTOPY\u5e93<\/strong>\uff1a\u5728\u4f7f\u7528Cartopy\u5e93\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u5b89\u88c5\u5b83\u3002\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>pip install cartopy<\/code>\u6765\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u5730\u56fe\u6295\u5f71<\/strong>\uff1a\u4f7f\u7528Cartopy\u5e93\u7684<code>ccrs<\/code>\u6a21\u5757\u521b\u5efa\u4e00\u4e2a\u5730\u56fe\u6295\u5f71\u5bf9\u8c61\u3002\u8fd9\u4e2a\u5bf9\u8c61\u53ef\u4ee5\u7528\u4e8e\u5b9a\u4e49\u5730\u56fe\u7684\u6295\u5f71\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ed8\u5236\u5730\u56fe<\/strong>\uff1a\u4f7f\u7528Matplotlib\u5e93\u7684<code>pyplot<\/code>\u6a21\u5757\u7ed8\u5236\u5730\u56fe\uff0c\u5e76\u6307\u5b9a\u4f7f\u7528Cartopy\u5e93\u7684\u5730\u56fe\u6295\u5f71\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u793a\u4f8b\u4ee3\u7801<\/p>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528Cartopy\u5e93\u8fdb\u884c\u5730\u56fe\u7ed8\u5236\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>import cartopy.crs as ccrs<\/p>\n<h2><strong>\u521b\u5efa\u5730\u56fe\u6295\u5f71<\/strong><\/h2>\n<p>projection = ccrs.Mercator()<\/p>\n<h2><strong>\u521b\u5efa\u5730\u56fe\u7ed8\u5236\u5bf9\u8c61<\/strong><\/h2>\n<p>fig, ax = plt.subplots(subplot_kw={&#39;projection&#39;: projection})<\/p>\n<h2><strong>\u7ed8\u5236\u6d77\u5cb8\u7ebf<\/strong><\/h2>\n<p>ax.coastlines()<\/p>\n<h2><strong>\u7ed8\u5236\u7f51\u683c\u7ebf<\/strong><\/h2>\n<p>ax.gridlines()<\/p>\n<h2><strong>\u663e\u793a\u5730\u56fe<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528Cartopy\u5e93\u7684Mercator\u6295\u5f71\uff08ccrs.Mercator()\uff09\u521b\u5efa\u4e86\u4e00\u4e2a\u5730\u56fe\u6295\u5f71\u5bf9\u8c61\uff0c\u5e76\u4f7f\u7528Matplotlib\u5e93\u7ed8\u5236\u4e86\u6d77\u5cb8\u7ebf\u548c\u7f51\u683c\u7ebf\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06\u5730\u7406\u6570\u636e\u7ed8\u5236\u5728\u4e0d\u540c\u7684\u5730\u56fe\u6295\u5f71\u4e0a\u3002<\/p>\n<\/p>\n<p><p>\u4e03\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\u5b9e\u73b0\u6295\u5f71\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528NumPy\u5e93\u8fdb\u884c\u77e9\u9635\u8fd0\u7b97\uff0c\u6216\u8005\u4f7f\u7528Pyproj\u5e93\u8fdb\u884c\u5750\u6807\u8f6c\u6362\u3002NumPy\u5e93\u9002\u7528\u4e8e\u7b80\u5355\u7684\u6295\u5f71\u8ba1\u7b97\uff0c\u800cPyproj\u5e93\u63d0\u4f9b\u4e86\u66f4\u9ad8\u5c42\u6b21\u7684\u5750\u6807\u8f6c\u6362\u529f\u80fd\uff0c\u652f\u6301\u591a\u79cd\u5730\u7406\u5750\u6807\u7cfb\u548c\u6295\u5f71\u65b9\u6cd5\u3002\u6b64\u5916\uff0cCartopy\u5e93\u53ef\u4ee5\u7528\u4e8e\u7ed8\u5236\u5730\u56fe\uff0c\u5e76\u652f\u6301\u591a\u79cd\u5730\u56fe\u6295\u5f71\u3002\u901a\u8fc7\u7ed3\u5408\u8fd9\u4e9b\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u5728Python\u4e2d\u8f7b\u677e\u5730\u5b9e\u73b0\u6295\u5f71\u548c\u5750\u6807\u8f6c\u6362\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b9a\u4e49\u6295\u5f71\u51fd\u6570\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5b9a\u4e49\u6295\u5f71\u51fd\u6570\u901a\u5e38\u6d89\u53ca\u4f7f\u7528NumPy\u6216Pandas\u5e93\u6765\u5904\u7406\u6570\u7ec4\u6216\u6570\u636e\u6846\u3002\u6295\u5f71\u51fd\u6570\u7684\u57fa\u672c\u601d\u8def\u662f\u5c06\u4e00\u4e2a\u5411\u91cf\u6295\u5f71\u5230\u53e6\u4e00\u4e2a\u5411\u91cf\u4e0a\u3002\u53ef\u4ee5\u901a\u8fc7\u8ba1\u7b97\u70b9\u79ef\u548c\u5f52\u4e00\u5316\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u4f8b\u5982\uff0c\u4f7f\u7528NumPy\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u4e00\u4e2a\u6295\u5f71\u51fd\u6570\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-python\">import numpy as np\n\ndef projection(a, b):\n    return (np.dot(a, b) \/ np.dot(b, b)) * b\n<\/code><\/pre>\n<p>\u6b64\u51fd\u6570\u63a5\u6536\u4e24\u4e2a\u5411\u91cf <code>a<\/code> \u548c <code>b<\/code> \u4f5c\u4e3a\u8f93\u5165\uff0c\u5e76\u8fd4\u56de <code>a<\/code> \u5728 <code>b<\/code> \u4e0a\u7684\u6295\u5f71\u3002<\/p>\n<p><strong>\u5728\u6570\u636e\u5206\u6790\u4e2d\u5982\u4f55\u5e94\u7528\u6295\u5f71\uff1f<\/strong><br \/>\u5728\u6570\u636e\u5206\u6790\u4e2d\uff0c\u6295\u5f71\u5e38\u7528\u4e8e\u964d\u7ef4\u5904\u7406\uff0c\u6bd4\u5982\u4e3b\u6210\u5206\u5206\u6790\uff08PCA\uff09\u3002\u901a\u8fc7\u5c06\u9ad8\u7ef4\u6570\u636e\u6295\u5f71\u5230\u4f4e\u7ef4\u7a7a\u95f4\uff0c\u5206\u6790\u5e08\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u53ef\u89c6\u5316\u6570\u636e\u5e76\u8bc6\u522b\u6a21\u5f0f\u3002\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Scikit-learn\u5e93\u7684PCA\u5b9e\u73b0\u8fd9\u4e00\u8fc7\u7a0b\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-python\">from sklearn.decomposition import PCA\n\npca = PCA(n_components=2)\nreduced_data = pca.fit_transform(original_data)\n<\/code><\/pre>\n<p>\u8fd9\u91cc <code>original_data<\/code> \u662f\u9ad8\u7ef4\u6570\u636e\uff0c<code>reduced_data<\/code> \u662f\u6295\u5f71\u5230\u4e8c\u7ef4\u7a7a\u95f4\u540e\u7684\u7ed3\u679c\u3002<\/p>\n<p><strong>\u5982\u4f55\u53ef\u89c6\u5316\u6295\u5f71\u7ed3\u679c\uff1f<\/strong><br \/>\u53ef\u89c6\u5316\u6295\u5f71\u7ed3\u679c\u662f\u7406\u89e3\u6570\u636e\u7684\u91cd\u8981\u4e00\u6b65\u3002\u53ef\u4ee5\u4f7f\u7528Matplotlib\u5e93\u6765\u7ed8\u5236\u6295\u5f71\u540e\u7684\u6570\u636e\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-python\">import matplotlib.pyplot as plt\n\nplt.scatter(reduced_data[:, 0], reduced_data[:, 1])\nplt.title(&#39;PCA Projection&#39;)\nplt.xlabel(&#39;Principal Component 1&#39;)\nplt.ylabel(&#39;Principal Component 2&#39;)\nplt.show()\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5c06\u6295\u5f71\u540e\u7684\u6570\u636e\u70b9\u7ed8\u5236\u6210\u6563\u70b9\u56fe\uff0c\u5e2e\u52a9\u7528\u6237\u76f4\u89c2\u7406\u89e3\u6570\u636e\u7684\u5206\u5e03\u60c5\u51b5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e00\u3001\u901a\u8fc7\u4f7f\u7528Python\u5e93\u5b9e\u73b0\u6295\u5f71\u3001\u5229\u7528NumPy\u8fdb\u884c\u77e9\u9635\u8fd0\u7b97\u3001\u4f7f\u7528Pyproj\u5e93\u8fdb\u884c\u5750\u6807\u8f6c\u6362 \u5728Python [&hellip;]","protected":false},"author":3,"featured_media":986549,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/986540"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=986540"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/986540\/revisions"}],"predecessor-version":[{"id":986552,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/986540\/revisions\/986552"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/986549"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=986540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=986540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=986540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}