编程与软件工程pbpython.com
高效使用 Matplotlib
Effectively Using Matplotlib
2017 — 2019,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是一篇系统讲解如何高效使用 Matplotlib 的教程,重点厘清 figure 与 axis 的区别、多种绘图接口,并建议采用面向对象接口。评论者认为这些看似基础的概念正是新手花大量时间才能搞明白的部分,同时也有不少人吐槽 Matplotlib 学习曲线陡、API 历史不一致。
为什么经久不衰:Matplotlib 仍是 Python 数据可视化的基础工具,而这篇教程把最容易混淆的核心概念讲得清楚,能帮读者少走弯路。
HN 评论精选
文章把 figure/axis 和面向对象接口讲清楚很有价值;多数场景可用 Seaborn,复杂需求可封装个人绘图库。
这篇文章很棒——哪怕只是解释 figure 和 axis 的区别、多种绘图系统(以及明智地推荐使用面向对象系统),就值回票价;这些东西花了我好几天撞墙和翻文档才搞明白。老实说,99% 的用途用 Seaborn 就很好,只要记得用最新版——很多人似乎装的是 0.8.0,而 API 在 0.9.0 变了。超出 Seaborn 能力的用途,最好的策略是搞出一套个人绘图语言,封装成个人库,这样就不用再反复想了。
paultopia查看英文原文
This post is great---even just explaining the difference between figure and axis, and the multiple systems (and the wise recommendation to use the OO system), and all the rest is gold---that stuff took me days of beating my head against the wall and searching through the matplotlib documentation to sort out. Honestly, for 99% of uses Seaborn is great, so long as you remember to use the latest version---for some reason, a lot of people seem to have 0.8.0 installed, and the api changed with 0.9.0. For uses beyond what Seaborn can do, I think that the best strategy is just to figure out a personal plotting language and then wrap that up into a personal library so you never have to think about that again. That's kind what I've done: I threw together a library to produce some basic figures that are suitable for printing,[1] and now I never have to think about those figures again. [1] https://github.com/paultopia/plottyprint
Matplotlib 虽啰嗦且 API 历史不一致,但为出版级图表值得投入时间。
Matplotlib 很啰嗦,过去 API 也不一致(v3 改善了很多),但如果你需要用 Python 产出出版质量的图,花时间熟悉它是值得的。我多年来用它做地图和数据可视化——每当我终于把某个图调好看,就把 notebook 放到 GitHub 上,既给自己参考,也给别人参考。
urschrei查看英文原文
Matplotlib is verbose, and has had an inconsistent API in the past (v3 has improved this a lot), but if you need to produce publication-quality figures using Python, taking the time to get comfortable with it pays off. I've been using it to produce maps and data visualisations for years – when I finally figure out how to make something look good, I put the notebook on Github, both for my own reference, and for others: https://github.com/urschrei/Geopython
推荐 Anatomy of Matplotlib 教程,尤其绘图方法概览速查表。
另一个有用的指南是 Ben Root 的 Anatomy of Matplotlib 教程。我有点偏心,因为我写了其中这一节(其余大部分是 Ben 的工作),但绘图方法概览是非常有用的速查表:它紧凑地可视化展示了主要绘图方法做什么以及它们之间的区别。
jofer查看英文原文
Another useful guide is Ben Root's Anatomy of Matplotlib tutorial: https://github.com/WeatherGod/AnatomyOfMatplotlib I'm a bit biased, as I wrote this particular section (most of the rest is Ben's work), but the plotting method overview is a very useful cheatsheet: http://nbviewer.jupyter.org/github/WeatherGod/AnatomyOfMatplotlib/blob/master/AnatomyOfMatplotlib-Part2-Plotting_Methods_Overview.ipynb It gives you a compact visual representation of what the main plotting methods do and the differences between them.
认为 Matplotlib 极不友好,建议改用 pandas plot、Seaborn、Altair 等替代方案。
Matplotlib 是我用过的最不友好的库之一。最有效的做法就是完全不用它。如果可以的话,用 pandas 的 plot、seaborn、altair 等。
blub查看英文原文
Matplotlib is one of the most user-unfriendly libraries I've had the displeasure to use. The most effective thing to do is to not use it at all. If you can get away with it use pandas' plot, seaborn, altair, etc.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选