专栏首页气象学家资源分享 | Python常用库Matplotlib的速查表

资源分享 | Python常用库Matplotlib的速查表

Matplotlib官网提供了一套全面的速查表,小编已经打包好了!

链接:https://pan.baidu.com/s/1cwR9klWVTRFUDDYiByDsqg  
密码:vcqv

手册里除了一些常用图形绘制、颜色选取,还有一些使用小技巧分享,另外,相关的脚本也都包含在压缩包内!对于熟悉Latex的小伙伴还可以自己编译文档!

使用Latex编译

You need to create a fonts repository with:

fonts/roboto/* : See https://fonts.google.com/specimen/Roboto
fonts/roboto-slab/* : See https://fonts.google.com/specimen/Roboto+Slab
fonts/source-code-pro/* : See https://fonts.google.com/specimen/Source+Code+Pro
fonts/source-sans-pro/* : See https://fonts.google.com/specimen/Source+Sans+Pro
fonts/source-serif-pro/* : See https://fonts.google.com/specimen/Source+Serif+Pro
fonts/delicious-123/* : See https://www.exljbris.com/delicious.html

You need to generate all the figures:

$ cd scripts
$ for script in *.py; do python $script; done
$ cd ..

Compile the sheet

$ xelatex cheatsheets.tex
$ xelatex cheatsheets.tex

Matplotlib History Note

The following introductory text was written in 2008 by John D. Hunter (1968-2012), the original author of Matplotlib.

Matplotlib is a library for making 2D plots of arrays in Python. Although it has its origins in emulating the MATLAB graphics commands, it is independent of MATLAB, and can be used in a Pythonic, object oriented way. Although Matplotlib is written primarily in pure Python, it makes heavy use of NumPy and other extension code to provide good performance even for large arrays.

Matplotlib is designed with the philosophy that you should be able to create simple plots with just a few commands, or just one! If you want to see a histogram of your data, you shouldn't need to instantiate objects, call methods, set properties, and so on; it should just work.

For years, I used to use MATLAB exclusively for data analysis and visualization. MATLAB excels at making nice looking plots easy. When I began working with EEG data, I found that I needed to write applications to interact with my data, and developed an EEG analysis application in MATLAB. As the application grew in complexity, interacting with databases, http servers, manipulating complex data structures, I began to strain against the limitations of MATLAB as a programming language, and decided to start over in Python. Python more than makes up for all of MATLAB's deficiencies as a programming language, but I was having difficulty finding a 2D plotting package (for 3D VTK more than exceeds all of my needs).

When I went searching for a Python plotting package, I had several requirements:

  • Plots should look great - publication quality. One important requirement for me is that the text looks good (antialiased, etc.)
  • Postscript output for inclusion with TeX documents
  • Embeddable in a graphical user interface for application development
  • Code should be easy enough that I can understand it and extend it
  • Making plots should be easy

Finding no package that suited me just right, I did what any self-respecting Python programmer would do: rolled up my sleeves and dived in. Not having any real experience with computer graphics, I decided to emulate MATLAB's plotting capabilities because that is something MATLAB does very well. This had the added advantage that many people have a lot of MATLAB experience, and thus they can quickly get up to steam plotting in python. From a developer's perspective, having a fixed user interface (the pylab interface) has been very useful, because the guts of the code base can be redesigned without affecting user code.

The Matplotlib code is conceptually divided into three parts: the pylab interface is the set of functions provided by pylab which allow the user to create plots with code quite similar to MATLAB figure generating code (Pyplot tutorial). The Matplotlib frontend or Matplotlib API is the set of classes that do the heavy lifting, creating and managing figures, text, lines, plots and so on (Artist tutorial). This is an abstract interface that knows nothing about output. The backends are device-dependent drawing devices, aka renderers, that transform the frontend representation to hardcopy or a display device (What is a backend?). Example backends: PS creates PostScript® hardcopy, SVG creates Scalable Vector Graphics hardcopy, Agg creates PNG output using the high quality Anti-Grain Geometry library that ships with Matplotlib, GTK embeds Matplotlib in a Gtk+ application, GTKAgg uses the Anti-Grain renderer to create a figure and embed it in a Gtk+ application, and so on for PDF, WxWidgets, Tkinter, etc.

Matplotlib is used by many people in many different contexts. Some people want to automatically generate PostScript files to send to a printer or publishers. Others deploy Matplotlib on a web application server to generate PNG output for inclusion in dynamically-generated web pages. Some use Matplotlib interactively from the Python shell in Tkinter on Windows. My primary use is to embed Matplotlib in a Gtk+ EEG application that runs on Windows, Linux and Macintosh OS X.

Citing Matplotlib

If Matplotlib contributes to a project that leads to a scientific publication, please acknowledge this fact by citing J. D. Hunter, "Matplotlib: A 2D Graphics Environment", Computing in Science & Engineering, vol. 9, no. 3, pp. 90-95, 2007.

@Article{Hunter:2007,
  Author    = {Hunter, J. D.},
  Title     = {Matplotlib: A 2D graphics environment},
  Journal   = {Computing in Science \& Engineering},
  Volume    = {9},
  Number    = {3},
  Pages     = {90--95},
  abstract  = {Matplotlib is a 2D graphics package used for Python for
  application development, interactive scripting, and publication-quality
  image generation across user interfaces and operating systems.},
  publisher = {IEEE COMPUTER SOC},
  doi       = {10.1109/MCSE.2007.55},
  year      = 2007
}

DOIs

The following DOI represents all Matplotlib versions. Please select a more specific DOI from the list below, referring to the version used for your publication.

本文分享自微信公众号 - 气象学家(Meteorologist2019),作者:gavin7675

原文出处及转载信息见文内详细说明,如有侵权,请联系 yunjia_community@tencent.com 删除。

原始发表时间:2020-07-12

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • 复合型极端气候:机器学习,统计方法和动力模拟

    最近Frontiers in Earth Science期刊组织一个专刊/专题 “复合型极端气候:机器学习,统计方法和动力模拟”。主要关注洪水,干旱,热浪,极端...

    气象学家
  • 原文|21世纪地理大数据

    By Jeff de La Beaujardière 25 November 2019

    气象学家
  • AMS推荐|气象学家-海洋学家的Python教程

    https://carpentrieslab.github.io/python-aos-lesson/

    气象学家
  • 首发|贾扬清回应[1小时训练ImageNet]:要关注这10个技术细节,窝里斗没有必要

    昨天,整个深度学习领域,几乎被一篇论文刷了屏。 论文指出,通过一种新的方法,能够大幅加速模型训练的过程,仅需1小时,就能训练完ImageNet这样的大规模数据集...

    AI科技大本营
  • 复合型极端气候:机器学习,统计方法和动力模拟

    最近Frontiers in Earth Science期刊组织一个专刊/专题 “复合型极端气候:机器学习,统计方法和动力模拟”。主要关注洪水,干旱,热浪,极端...

    气象学家
  • 如何用Postman创建SAP CRM的Opportunity业务数据

    Subject: How to create Opportunity note in Chrome for testing purpose

    Jerry Wang
  • 复合型极端气候:机器学习,统计方法和动力模拟

    最近Frontiers in Earth Science期刊组织一个专刊/专题 “复合型极端气候:机器学习,统计方法和动力模拟”。主要关注洪水,干旱,热浪,极端...

    bugsuse
  • 复合型极端气候:机器学习,统计方法和动力模拟

    最近Frontiers in Earth Science期刊组织一个专刊/专题 “复合型极端气候:机器学习,统计方法和动力模拟”。主要关注洪水,干旱,热浪,极端...

    zhangqibot
  • ros2之tello无人机

    版权声明:署名,允许他人基于本文进行创作,且必须基于与原先许可协议相同的许可协议分发本文 (Creative Commons)

    zhangrelay
  • Meteor 1.3 正式发布啦!ES 2015模块,应用测试,移动提升等新特性

    时见疏星

扫码关注云+社区

领取腾讯云代金券