美文网首页
python 第三方库中添加需求代码

python 第三方库中添加需求代码

作者: ab02f58fd803 | 来源:发表于2020-09-10 19:33 被阅读0次

绘制 min-mean-max plot

这种类似的函数使用的seabornsns.pointplot()实现,其中ci是我们选择的置信区间,也可以选择sd,置信区间是标准差。

根据我们实际需求,我们要求实现min-mean-maxpointplot()的绘制,相关文献如下[1]:

minmeanmax.png

但是我们需要minmax绘制区间,因此,这里需要对已经下载的../site-packages/..进行代码修改。
经过探索发现这个函数实现在./seaborn/categorical.py的文件中,经过在文件中对pointplot()函数的搜索,找到_PointPlotter,再对其进行搜索,找到_CategoricalStatPlotter,发现_PointPlotter继承了_CategoricalStatPlotter这个类,因此继续搜索_CategoricalStatPlotter,找到了estimate_statistic()函数下的对ci判断实现。如下图:

ci.png

这个是我已经修改好的函数,但是这样是不可以的,详见stackoverflow。根据上面的提示,我进行了如下操作:

  1. Github下载seaborn的原始代码。
  2. 放在./python/development/文件夹下。
  3. 在对应的./seaborn/categorical.py文件中修改相应的代码。
  4. 使用python setup.py develop生成对应开发者模式的代码。

这样就可以在我的电脑生成对应的图像了。如下图

minmax.png

notes:

  1. 为了使用这个修改版本的seaborn,必须卸载原始../site-packages/..路径下的seaborn,pip uninstall seaborn

  2. 将修改后的路径加入到环境变量path中。

  3. 这个只能是自己能使用,如果做出贡献,可以github给作者留言,添加这样的代码。

  4. 如果自己有小的需求,也可以通过这样方式对库进行修改。

[1] Ayad Ali Faris B., Ahmed H. A.-S., Adrian O., Anna J. and Adriana M. (2016). "Estimation of Evapotranspiration Using SEBAL Algorithm and Landsat-8 Data—A Case Study: Tatra Mountains Region." Journal of Geological Resource and Engineering 4(6).

相关文章

网友评论

      本文标题:python 第三方库中添加需求代码

      本文链接:https://www.haomeiwen.com/subject/dxxmektx.html