{"id":5058,"date":"2022-04-01T22:36:47","date_gmt":"2022-04-01T14:36:47","guid":{"rendered":"https:\/\/egonlin.com\/?p=5058"},"modified":"2022-04-02T18:06:45","modified_gmt":"2022-04-02T10:06:45","slug":"07-%e7%82%ab%e9%85%b7%e7%9a%84%e5%8f%af%e8%a7%86%e5%8c%96%e5%b7%a5%e5%85%b7%e5%8c%85-cufflinks","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=5058","title":{"rendered":"07 \u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u5305\u2014\u2014cufflinks"},"content":{"rendered":"<h1>\u524d\u8a00<\/h1>\n<p>\u5b66\u8fc7Python\u6570\u636e\u5206\u6790\u7684\u670b\u53cb\u90fd\u77e5\u9053\uff0c\u5728\u53ef\u89c6\u5316\u7684\u5de5\u5177\u4e2d\uff0c\u6709\u5f88\u591a\u4f18\u79c0\u7684\u4e09\u65b9\u5e93\uff0c\u6bd4\u5982matplotlib\uff0cseaborn\uff0cplotly\uff0cBoken\uff0cpyecharts\u7b49\u7b49\u3002\u8fd9\u4e9b\u53ef\u89c6\u5316\u5e93\u90fd\u6709\u81ea\u5df1\u7684\u7279\u70b9\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u4e5f\u5e7f\u4e3a\u5927\u5bb6\u4f7f\u7528\u3002<\/p>\n<p>plotly\u3001Boken\u7b49\u90fd\u662f\u4ea4\u4e92\u5f0f\u7684\u53ef\u89c6\u5316\u5de5\u5177\uff0c\u7ed3\u5408Jupyter notebook\u53ef\u4ee5\u975e\u5e38\u7075\u6d3b\u65b9\u4fbf\u5730\u5c55\u73b0\u5206\u6790\u540e\u7684\u7ed3\u679c\u3002\u867d\u7136\u505a\u51fa\u7684\u6548\u679c\u975e\u5e38\u7684\u70ab\u9177\uff0c\u6bd4\u5982plotly\uff0c\u4f46\u662f\u6bcf\u4e00\u6b21\u90fd\u9700\u8981\u5199\u5f88\u957f\u7684\u4ee3\u7801\uff0c\u4e00\u662f\u9ebb\u70e6\uff0c\u4e8c\u662f\u4e0d\u4fbf\u4e8e\u7ef4\u62a4\u3002<\/p>\n<p>\u6211\u89c9\u5f97\u5728\u6570\u636e\u7684\u5206\u6790\u9636\u6bb5\uff0c\u66f4\u591a\u7684\u65f6\u95f4\u5e94\u8be5\u653e\u5728\u5206\u6790\u4e0a\uff0c\u7ef4\u5ea6\u9009\u62e9\u3001\u62c6\u89e3\u5408\u5e76\uff0c\u4e1a\u52a1\u7406\u89e3\u548c\u5224\u65ad\u3002\u5982\u679c\u65e2\u53ef\u4ee5\u51cf\u5c11\u4ee3\u7801\u91cf\uff0c\u53c8\u53ef\u4ee5\u505a\u51fa\u70ab\u9177\u53ef\u89c6\u5316\u6548\u679c\uff0c\u90a3\u5c06\u5927\u5927\u63d0\u9ad8\u6548\u7387\u3002\u5f53\u7136\u5982\u679c\u6709\u7279\u522b\u7684\u9700\u6c42\u9664\u5916\uff0c\u6b64\u65b9\u6cd5\u4ec5\u9488\u5bf9\u60f3\u8981\u5feb\u901f\u53ef\u89c6\u5316\u8fdb\u884c\u5206\u6790\u7684\u4eba\u3002<\/p>\n<p>\u672c\u7bc7\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4e00\u4e2a\u975e\u5e38\u68d2\u7684\u5de5\u5177\uff0ccufflinks\uff0c\u53ef\u4ee5\u5b8c\u7f8e\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898,\u4e14\u6548\u679c\u4e00\u6837\u70ab\u9177\u3002<\/p>\n<h1>cufflinks\u4ecb\u7ecd<\/h1>\n<p>\u5c31\u50cfseaborn\u5c01\u88c5\u4e86matplotlib\u4e00\u6837\uff0ccufflinks\u5728plotly\u7684\u57fa\u7840\u4e0a\u505a\u4e86\u4e00\u8fdb\u4e00\u6b65\u7684\u5305\u88c5\uff0c\u65b9\u6cd5\u7edf\u4e00\uff0c\u53c2\u6570\u914d\u7f6e\u7b80\u5355\u3002\u5176\u6b21\u5b83\u8fd8\u53ef\u4ee5\u7ed3\u5408pandas\u7684dataframe\u968f\u610f\u7075\u6d3b\u5730\u753b\u56fe\u3002\u53ef\u4ee5\u628a\u5b83\u5f62\u5bb9\u4e3a&quot;pandas like visualization&quot;\u3002<\/p>\n<p>\u6beb\u4e0d\u5938\u5f20\u5730\u8bf4\uff0c\u753b\u51fa\u5404\u79cd\u70ab\u9177\u7684\u53ef\u89c6\u5316\u56fe\u5f62\uff0c\u6211\u53ea\u9700\u4e00\u884c\u4ee3\u7801\uff0c\u6548\u7387\u975e\u5e38\u9ad8\uff0c\u540c\u65f6\u4e5f\u964d\u4f4e\u4e86\u4f7f\u7528\u7684\u95e8\u69db\u513f\u3002cufflinks\u7684github\u94fe\u63a5\u5982\u4e0b\uff1a<br \/>\n<a href=\"https:\/\/github.com\/santosjorge\/cufflinks\">https:\/\/github.com\/santosjorge\/cufflinks<\/a><\/p>\n<h1>\u5b89\u88c5<\/h1>\n<pre><code class=\"language-python\">pip install cufflinks<\/code><\/pre>\n<h1>cufflinks\u64cd\u4f5c<\/h1>\n<p>cufflinks\u5e93\u4e00\u76f4\u5728\u4e0d\u65ad\u66f4\u65b0\uff0c\u76ee\u524d\u6700\u65b0\u7248\u4e3aV0.14.0\uff0c\u652f\u6301plotly3.0\u3002\u9996\u5148\u6211\u4eec\u770b\u770b\u5b83\u90fd\u652f\u6301\u54ea\u4e9b\u79cd\u7c7b\u7684\u56fe\u5f62\uff0c\u53ef\u4ee5\u901a\u8fc7help\u6765\u67e5\u770b\u3002<\/p>\n<pre><code class=\"language-python\">import cufflinks as cf<\/code><\/pre>\n<pre><code class=\"language-python\">cf.help()<\/code><\/pre>\n<pre><code>Use &#039;cufflinks.help(figure)&#039; to see the list of available parameters for the given figure.\nUse &#039;DataFrame.iplot(kind=figure)&#039; to plot the respective figure\nFigures:\n    bar\n    box\n    bubble\n    bubble3d\n    candle\n    choroplet\n    distplot\n    heatmap\n    histogram\n    ohlc\n    pie\n    ratio\n    scatter\n    scatter3d\n    scattergeo\n    spread\n    surface\n    violin<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53051.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53051.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<ul>\n<li>DataFrame\uff1a\u4ee3\u8868pandas\u7684\u6570\u636e\u6846\uff1b<\/li>\n<li>Figure\uff1a\u4ee3\u8868\u6211\u4eec\u4e0a\u9762\u770b\u5230\u7684\u53ef\u7ed8\u5236\u56fe\u5f62\uff0c\u6bd4\u5982bar\u3001box\u3001histogram\u7b49\u7b49\uff1b<\/li>\n<li>iplot\uff1a\u4ee3\u8868\u7ed8\u5236\u65b9\u6cd5\uff0c\u5176\u4e2d\u6709\u5f88\u591a\u53c2\u6570\u53ef\u4ee5\u8fdb\u884c\u914d\u7f6e\uff0c\u8c03\u8282\u7b26\u5408\u4f60\u81ea\u5df1\u98ce\u683c\u7684\u53ef\u89c6\u5316\u56fe\u5f62\uff1b<\/li>\n<\/ul>\n<h1>cufflinks\u5b9e\u4f8b<\/h1>\n<div style=\"color:red;font-size:28px\">\u6ce8\u610f\uff1a\u4ee5\u4e0b\u56fe\u4f8b\u90fd\u662f\u52a8\u6001\u56fe\uff0c\u65e0\u6cd5\u653e\u7f6egif\u56fe\uff0c\u53ef\u4ee5\u81ea\u5df1\u5c1d\u8bd5\u4e00\u4e0b<\/div>\n<p>\u6211\u4eec\u901a\u8fc7\u51e0\u4e2a\u5b9e\u4f8b\u611f\u53d7\u4e00\u4e0b\u4e0a\u9762\u7684\u4f7f\u7528\u65b9\u6cd5\u3002\u4f7f\u7528\u8fc7plotly\u7684\u670b\u53cb\u53ef\u80fd\u77e5\u9053\uff0c\u5982\u679c\u4f7f\u7528online\u6a21\u5f0f\uff0c\u90a3\u4e48\u751f\u6210\u7684\u56fe\u5f62\u662f\u6709\u9650\u5236\u7684\u3002\u6240\u4ee5\uff0c\u6211\u4eec\u8fd9\u91cc\u5148\u8bbe\u7f6e\u4e3aoffline\u6a21\u5f0f\uff0c\u8fd9\u6837\u5c31\u907f\u514d\u4e86\u51fa\u73b0\u6b21\u6570\u9650\u5236\u95ee\u9898\u3002<\/p>\n<pre><code class=\"language-python\">import pandas as pd\nimport cufflinks as cf\nimport numpy as np\n\ncf.set_config_file(offline=True)<\/code><\/pre>\n<pre><code>    &lt;script type=&quot;text\/javascript&quot;&gt;\n    window.PlotlyConfig = {MathJaxConfig: &#039;local&#039;};\n    if (window.MathJax) {MathJax.Hub.Config({SVG: {font: &quot;STIX-Web&quot;}});}\n    if (typeof require !== &#039;undefined&#039;) {\n    require.undef(&quot;plotly&quot;);\n    requirejs.config({\n        paths: {\n            &#039;plotly&#039;: [&#039;https:\/\/cdn.plot.ly\/plotly-latest.min&#039;]\n        }\n    });\n    require([&#039;plotly&#039;], function(Plotly) {\n        window._Plotly = Plotly;\n    });\n    }\n    &lt;\/script&gt;<\/code><\/pre>\n<p>\u7136\u540e\u6211\u4eec\u9700\u8981\u6309\u7167\u4e0a\u9762\u7684\u4f7f\u7528\u683c\u5f0f\u6765\u64cd\u4f5c\uff0c\u9996\u5148\u6211\u4eec\u9700\u8981\u6709\u4e2aDataFrame\uff0c\u5982\u679c\u624b\u5934\u6ca1\u5565\u6570\u636e\uff0c\u90a3\u53ef\u4ee5\u5148\u751f\u6210\u4e2a\u968f\u673a\u6570\u3002cufflinks\u6709\u4e00\u4e2a\u4e13\u95e8\u751f\u6210\u968f\u673a\u6570\u7684\u65b9\u6cd5\uff0c\u53eb\u505adatagen\uff0c\u7528\u4e8e\u751f\u6210\u4e0d\u540c\u7ef4\u5ea6\u7684\u968f\u673a\u6570\u636e\uff0c\u6bd4\u5982\u4e0b\u9762\u3002<\/p>\n<h2>lines\u7ebf\u56fe<\/h2>\n<p>1\uff09cufflinks\u4f7f\u7528datagen\u751f\u6210\u968f\u673a\u6570\uff1b<br \/>\n2\uff09figure\u5b9a\u4e49\u4e3alines\u5f62\u5f0f\uff0c\u6570\u636e\u4e3a(1,500)\uff1b<br \/>\n3\uff09\u7136\u540e\u518d\u7528ta_plot\u7ed8\u5236\u8fd9\u4e00\u7ec4\u65f6\u95f4\u5e8f\u5217\uff0c\u53c2\u6570\u8bbe\u7f6eSMA\u5c55\u73b0\u4e09\u4e2a\u4e0d\u540c\u5468\u671f\u7684\u65f6\u5e8f\u5206\u6790\u3002<\/p>\n<pre><code class=\"language-python\">cf.datagen.lines(1,500).ta_plot(study=&#039;sma&#039;,period=[13,21,55])\n<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53052.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53052.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<h2>box\u7bb1\u578b\u56fe<\/h2>\n<pre><code class=\"language-python\">cf.datagen.box(20).iplot(kind=&#039;box&#039;,legend=False)<\/code><\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\uff0cx\u8f74\u6bcf\u4e2abox\u90fd\u6709\u5bf9\u5e94\u7684\u540d\u79f0\uff0c\u8fd9\u662f\u56e0\u4e3acufflinks\u901a\u8fc7kind\u53c2\u6570\u8bc6\u522b\u4e86box\u56fe\u5f62\uff0c\u81ea\u52a8\u4e3a\u5b83\u751f\u6210\u7684\u540d\u5b57\u3002\u5982\u679c\u6211\u4eec\u53ea\u751f\u6210\u968f\u673a\u6570\uff0c\u5b83\u662f\u8fd9\u6837\u5b50\u7684\uff0c\u9ed8\u8ba4\u751f\u6210100\u884c\u7684\u968f\u673a\u5206\u5e03\u7684\u6570\u636e\uff0c\u5217\u6570\u7531\u81ea\u5df1\u9009\u5b9a\u3002<\/p>\n<pre><code class=\"language-python\">cf.datagen.box(10)\n<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53053.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53053.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }<\/p>\n<p>```\n.dataframe tbody tr th {\n    vertical-align: top;\n}<\/p>\n<p>.dataframe thead th {\n    text-align: right;\n}<\/p>\n<p>```<\/p>\n<\/style>\n<table border=\"1\" class=\"dataframe\">\n<thead>\n<tr style=\"text-align: right;\">\n<th><\/th>\n<th>ZZQ.IX<\/th>\n<th>KKT.HE<\/th>\n<th>WUI.GF<\/th>\n<th>KUD.YP<\/th>\n<th>LVO.BR<\/th>\n<th>RIQ.OH<\/th>\n<th>HCY.AX<\/th>\n<th>TSI.WB<\/th>\n<th>CZC.FE<\/th>\n<th>PGJ.UN<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>0<\/th>\n<td>2.650637<\/td>\n<td>2.860086<\/td>\n<td>0.648258<\/td>\n<td>0.453637<\/td>\n<td>0.031173<\/td>\n<td>1.588635<\/td>\n<td>0.665888<\/td>\n<td>1.322199<\/td>\n<td>0.613859<\/td>\n<td>1.887332<\/td>\n<\/tr>\n<tr>\n<th>1<\/th>\n<td>1.772565<\/td>\n<td>1.223209<\/td>\n<td>1.321523<\/td>\n<td>5.185581<\/td>\n<td>4.585844<\/td>\n<td>2.950900<\/td>\n<td>0.652469<\/td>\n<td>0.471112<\/td>\n<td>5.729238<\/td>\n<td>3.034579<\/td>\n<\/tr>\n<tr>\n<th>2<\/th>\n<td>3.707357<\/td>\n<td>5.745729<\/td>\n<td>5.766174<\/td>\n<td>1.785150<\/td>\n<td>8.335558<\/td>\n<td>17.388996<\/td>\n<td>2.854110<\/td>\n<td>5.725720<\/td>\n<td>9.582913<\/td>\n<td>1.221468<\/td>\n<\/tr>\n<tr>\n<th>3<\/th>\n<td>9.298724<\/td>\n<td>8.008446<\/td>\n<td>2.574685<\/td>\n<td>3.924959<\/td>\n<td>5.656232<\/td>\n<td>8.797833<\/td>\n<td>18.606412<\/td>\n<td>10.594716<\/td>\n<td>1.207231<\/td>\n<td>3.901563<\/td>\n<\/tr>\n<tr>\n<th>4<\/th>\n<td>5.261365<\/td>\n<td>3.498773<\/td>\n<td>4.593977<\/td>\n<td>6.516262<\/td>\n<td>3.852370<\/td>\n<td>3.402193<\/td>\n<td>2.813485<\/td>\n<td>2.340898<\/td>\n<td>7.611254<\/td>\n<td>5.423463<\/td>\n<\/tr>\n<tr>\n<th>&#8230;<\/th>\n<td>&#8230;<\/td>\n<td>&#8230;<\/td>\n<td>&#8230;<\/td>\n<td>&#8230;<\/td>\n<td>&#8230;<\/td>\n<td>&#8230;<\/td>\n<td>&#8230;<\/td>\n<td>&#8230;<\/td>\n<td>&#8230;<\/td>\n<td>&#8230;<\/td>\n<\/tr>\n<tr>\n<th>95<\/th>\n<td>0.136329<\/td>\n<td>2.676648<\/td>\n<td>0.403378<\/td>\n<td>1.018672<\/td>\n<td>1.447996<\/td>\n<td>1.106163<\/td>\n<td>1.563319<\/td>\n<td>6.315881<\/td>\n<td>1.148427<\/td>\n<td>0.348217<\/td>\n<\/tr>\n<tr>\n<th>96<\/th>\n<td>4.243743<\/td>\n<td>0.026604<\/td>\n<td>0.442303<\/td>\n<td>2.650356<\/td>\n<td>7.911090<\/td>\n<td>1.048235<\/td>\n<td>3.231528<\/td>\n<td>0.850884<\/td>\n<td>0.336564<\/td>\n<td>0.301514<\/td>\n<\/tr>\n<tr>\n<th>97<\/th>\n<td>2.223366<\/td>\n<td>3.581352<\/td>\n<td>2.712159<\/td>\n<td>1.141006<\/td>\n<td>1.841442<\/td>\n<td>4.167166<\/td>\n<td>10.543993<\/td>\n<td>5.589251<\/td>\n<td>12.338148<\/td>\n<td>4.013969<\/td>\n<\/tr>\n<tr>\n<th>98<\/th>\n<td>1.391020<\/td>\n<td>0.002552<\/td>\n<td>0.177377<\/td>\n<td>1.865509<\/td>\n<td>0.690297<\/td>\n<td>0.682517<\/td>\n<td>7.477029<\/td>\n<td>0.261913<\/td>\n<td>0.020654<\/td>\n<td>0.822866<\/td>\n<\/tr>\n<tr>\n<th>99<\/th>\n<td>0.229824<\/td>\n<td>1.756769<\/td>\n<td>1.782207<\/td>\n<td>3.621471<\/td>\n<td>1.523997<\/td>\n<td>4.392876<\/td>\n<td>0.403206<\/td>\n<td>6.899078<\/td>\n<td>1.268289<\/td>\n<td>7.484547<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>100 rows \u00d7 10 columns<\/p>\n<\/div>\n<h2>histogram\u76f4\u65b9\u56fe<\/h2>\n<pre><code class=\"language-python\">cf.datagen.histogram(3).iplot(kind=&#039;histogram&#039;)\n<\/code><\/pre>\n<p>\u548cplotly\u4e00\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e9b\u8f85\u52a9\u7684\u5c0f\u5de5\u5177\u6846\u9009\u6216\u8005lasso\u9009\u62e9\u6765\u533a\u5206\u548c\u9009\u5b9a\u6307\u5b9a\u533a\u57df\uff0c\u53ea\u8981\u4e00\u884c\u4ee3\u7801\u3002<\/p>\n<p>\u5f53\u7136\u4e86\uff0c\u9664\u4e86\u968f\u673a\u6570\u636e\uff0c\u4efb\u4f55\u7684\u5176\u5b83dataframe\u6570\u636e\u6846\u90fd\u53ef\u4ee5\uff0c\u5305\u62ec\u6211\u4eec\u81ea\u5df1\u5bfc\u5165\u7684\u6570\u636e\u3002<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53054.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53054.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<h2>histogram\u6761\u5f62\u56fe<\/h2>\n<pre><code class=\"language-python\">df=pd.DataFrame(np.random.rand(10, 4), columns=[&#039;a&#039;, &#039;b&#039;, &#039;c&#039;, &#039;d&#039;])\ndf.iplot(kind=&#039;bar&#039;,barmode=&#039;stack&#039;)\n<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53055.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53055.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u4e0a\u9762\u6211\u4eec\u751f\u6210\u4e86\u4e00\u4e2a(10,4)\u7684dataframe\u6570\u636e\u6846\uff0c\u540d\u79f0\u5206\u522b\u662fa,b,c,d\u3002\u90a3\u4e48cufflinks\u5c06\u4f1a\u6839\u636eiplot\u4e2d\u7684kind\u79cd\u7c7b\u81ea\u52a8\u8bc6\u522b\u5e76\u7ed8\u5236\u56fe\u5f62\u3002\u53c2\u6570\u8bbe\u7f6e\u4e3a\u5806\u53e0\u6a21\u5f0f\u3002<\/p>\n<h2>scatter\u6563\u70b9\u56fe<\/h2>\n<pre><code class=\"language-python\">df = pd.DataFrame(np.random.rand(50, 4), columns=[&#039;a&#039;, &#039;b&#039;, &#039;c&#039;, &#039;d&#039;])\ndf.iplot(kind=&#039;scatter&#039;,mode=&#039;markers&#039;,colors=[&#039;orange&#039;,&#039;teal&#039;,&#039;blue&#039;,&#039;yellow&#039;],size=10)\n<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53056.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53056.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<h2>bubble\u6c14\u6ce1\u56fe<\/h2>\n<pre><code class=\"language-python\">df.iplot(kind=&#039;bubble&#039;,x=&#039;a&#039;,y=&#039;b&#039;,size=&#039;c&#039;)\n<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53057.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53057.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<h2>scatter matrix  \u6563\u70b9\u77e9\u9635\u56fe<\/h2>\n<pre><code class=\"language-python\">df = pd.DataFrame(np.random.randn(1000, 4), columns=[&#039;a&#039;, &#039;b&#039;, &#039;c&#039;, &#039;d&#039;])\ndf.scatter_matrix()\n<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53058.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53058.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<h2>subplots\u5b50\u56fe<\/h2>\n<pre><code class=\"language-python\">df=cf.datagen.lines(4)\ndf.iplot(subplots=True,shape=(4,1),shared_xaxes=True,vertical_spacing=.02,fill=True)\n<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53059.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u53059.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<pre><code class=\"language-python\">df.iplot(subplots=True,subplot_titles=True,legend=False)\n<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u530510.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u530510.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u66f4\u590d\u6742\u4e00\u4e9b\u7684<\/p>\n<pre><code class=\"language-python\">df=cf.datagen.bubble(10,50,mode=&#039;stocks&#039;)\nfigs=cf.figures(df,[dict(kind=&#039;histogram&#039;,keys=&#039;x&#039;,color=&#039;blue&#039;),\n                    dict(kind=&#039;scatter&#039;,mode=&#039;markers&#039;,x=&#039;x&#039;,y=&#039;y&#039;,size=5),\n                    dict(kind=&#039;scatter&#039;,mode=&#039;markers&#039;,x=&#039;x&#039;,y=&#039;y&#039;,size=5,color=&#039;teal&#039;)],asList=True)\nfigs.append(cf.datagen.lines(1).figure(bestfit=True,colors=[&#039;blue&#039;],bestfit_colors=[&#039;pink&#039;]))\nbase_layout=cf.tools.get_base_layout(figs)\nsp=cf.subplots(figs,shape=(3,2),base_layout=base_layout,vertical_spacing=.15,horizontal_spacing=.03,\n               specs=[[{&#039;rowspan&#039;:2},{}],[None,{}],[{&#039;colspan&#039;:2},None]],\n               subplot_titles=[&#039;Histogram&#039;,&#039;Scatter 1&#039;,&#039;Scatter 2&#039;,&#039;Bestfit Line&#039;])\nsp[&#039;layout&#039;].update(showlegend=False)\ncf.iplot(sp)\n<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u530511.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u530511.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u200b        <\/p>\n<h2>shapes\u5f62\u72b6\u56fe<\/h2>\n<p>\u5982\u679c\u6211\u4eec\u60f3\u5728lines\u56fe\u4e0a\u589e\u52a0\u4e00\u4e9b\u76f4\u7ebf\u4f5c\u4e3a\u53c2\u8003\u57fa\u51c6\uff0c\u8fd9\u65f6\u5019\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528hlines\u7684\u7c7b\u578b\u56fe\u3002<\/p>\n<pre><code class=\"language-python\">df=cf.datagen.lines(3,columns=[&#039;a&#039;,&#039;b&#039;,&#039;c&#039;])\ndf.iplot(hline=[dict(y=-1,color=&#039;blue&#039;,width=3),dict(y=1,color=&#039;pink&#039;,dash=&#039;dash&#039;)])<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u530512.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u530512.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u6216\u8005\u662f\u5c06\u67d0\u4e2a\u533a\u57df\u6807\u8bb0\u51fa\u6765\uff0c\u53ef\u4ee5\u4f7f\u7528hspan\u7c7b\u578b\u3002<\/p>\n<pre><code class=\"language-python\">df.iplot(hspan=[(-1,1),(2,5)])<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u530513.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u530513.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u53c8\u6216\u8005\u662f\u7ad6\u6761\u7684\u533a\u57df\uff0c\u53ef\u4ee5\u7528vspan\u7c7b\u578b\u3002<\/p>\n<pre><code class=\"language-python\">df.iplot(vspan={&#039;x0&#039;:&#039;2015-02-15&#039;,&#039;x1&#039;:&#039;2015-03-15&#039;,&#039;color&#039;:&#039;teal&#039;,&#039;fill&#039;:True,&#039;opacity&#039;:.4})\n<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u530514.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2022\/04\/\u70ab\u9177\u7684\u53ef\u89c6\u5316\u5de5\u5177\u530514.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><br \/>\n\u5982\u679c\u5bf9iplot\u4e2d\u7684\u53c2\u6570\u4e0d\u719f\u7ec3\uff0c\u76f4\u63a5\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\u5373\u53ef\u67e5\u8be2\u3002<\/p>\n<pre><code class=\"language-python\">help(df.iplot)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u5b66\u8fc7Python\u6570\u636e\u5206\u6790\u7684\u670b\u53cb\u90fd\u77e5\u9053\uff0c\u5728\u53ef\u89c6\u5316\u7684\u5de5\u5177\u4e2d\uff0c\u6709\u5f88\u591a\u4f18\u79c0\u7684\u4e09\u65b9\u5e93\uff0c\u6bd4\u5982matplotlib\uff0cs [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":5065,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[371,378],"tags":[],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/5058"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5058"}],"version-history":[{"count":0,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/5058\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/media\/5065"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5058"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5058"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5058"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}