From a9960a3b7c2cd05798f8c02f876dcdc107d1d944 Mon Sep 17 00:00:00 2001 From: wizardforcel <562826179@qq.com> Date: Sun, 8 Jan 2017 18:59:23 +0800 Subject: [PATCH] 3.8 --- 3.8.md | 220 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 3.8.md diff --git a/3.8.md b/3.8.md new file mode 100644 index 0000000..a4bb5f0 --- /dev/null +++ b/3.8.md @@ -0,0 +1,220 @@ +# 3.8 屏幕截图 + +> 原文:[Screenshots](http://matplotlib.org/users/screenshots.html) + +> 译者:[飞龙](https://github.com/) + +> 协议:[CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/) + +这里你会找到一些示例图和生成它们的代码。 + +## 简单绘图 + +这里是一个带有文本标签的基本的绘图: + +[源代码](http://matplotlib.org/mpl_examples/pylab_examples/simple_plot.py) + +![](http://matplotlib.org/_images/simple_plot1.png) + +## 子图示例 + +多个轴域(例如子图)可使用`subplot()`命令创建: + +[源代码](http://matplotlib.org/mpl_examples/subplots_axes_and_figures/subplot_demo.py) + +![](http://matplotlib.org/_images/subplot_demo3.png) + +## 直方图 + +`hist()`命令自动生成直方图,并返回项数或者概率: + +[源代码](http://matplotlib.org/mpl_examples/statistics/histogram_demo_features.py) + +![](http://matplotlib.org/_images/histogram_demo_features2.png) + +## 路径示例 + +你可以使用` matplotlib.path`模块,在`maplotlib`中添加任意路径: + +[源代码](http://matplotlib.org/mpl_examples/shapes_and_collections/path_patch_demo.py) + +![](http://matplotlib.org/_images/path_patch_demo1.png) + +## mplot3d + +mplot3d 工具包(见 [mplot3d 教程](http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#toolkit-mplot3d-tutorial)和 [mplot3d 示例](http://matplotlib.org/examples/mplot3d/index.html#mplot3d-examples-index))支持简单的三维图形,包括平台、线框图、散点图和条形图。 + +[源代码](http://matplotlib.org/mpl_examples/mplot3d/surface3d_demo.py) + +![](http://matplotlib.org/_images/surface3d_demo4.png) + +感谢 John Porter,Jonathan Taylor,Reinier Heeres 和 Ben Root 开发了 mplot3d 工具包。 此工具包包含于所有标准 matplotlib 安装中。 + +## Streamplot + +`streamplot()`函数绘制向量场的流线图。 除了简单地绘制流线之外,它还允许将流线的颜色和/或线宽映射到单独的参数,例如向量场的速度或局部密度。 + +[源代码](http://matplotlib.org/mpl_examples/images_contours_and_fields/streamplot_demo_features.py) + +![](http://matplotlib.org/_images/streamplot_demo_features_001.png) + +![](http://matplotlib.org/_images/streamplot_demo_features_011.png) + +这个特性完善了绘制向量场的`quiver()`函数。 感谢 Tom Flanagan 和 Tony You 添加`streamplot`函数。 + +## 椭圆 + +为了支持 [Phoenix Mars Mission](http://www.jpl.nasa.gov/news/phoenix/main.php)(使用 matplotlib 展示地面跟踪的航天器),Michael Droettboom 在 Charlie Moad 的工作基础上提供了非常精确的椭圆弧的 8-样条近似(见[`Arc`](http://matplotlib.org/api/patches_api.html#matplotlib.patches.Arc)),它对缩放级别并不敏感。 + +[源代码](http://matplotlib.org/mpl_examples/pylab_examples/ellipse_demo.py) + +![](http://matplotlib.org/_images/ellipse_demo1.png) + +## 条形图 + +使用`bar()`命令创建条形图十分容易,其中包括一些定制(如误差条): + +[源代码](http://matplotlib.org/mpl_examples/pylab_examples/barchart_demo.py) + +![](http://matplotlib.org/_images/barchart_demo3.png) + +创建堆叠条([`bar_stacked.py`](http://matplotlib.org/examples/pylab_examples/bar_stacked.html)),蜡烛条([`finance_demo.py`](http://matplotlib.org/examples/pylab_examples/finance_demo.html))和水平条形图([`barh_demo.py`](http://matplotlib.org/examples/lines_bars_and_markers/barh_demo.html))也很简单。 + +## 饼图 + +`pie()`命令允许您轻松创建饼图。 可选功能包括自动标记区域的百分比,从饼图中心向外生成一个或多个楔形以及阴影效果。 仔细查看附加的代码,它用几行代码来生成这个图像。 + +[源代码](http://matplotlib.org/mpl_examples/pie_and_polar_charts/pie_demo_features.py) + +![](http://matplotlib.org/_images/pie_demo_features_001.png) + +![](http://matplotlib.org/_images/pie_demo_features_011.png) + +## 表格示例 + +`table()`命令向轴域添加文本表格。 + +[源代码](http://matplotlib.org/mpl_examples/pylab_examples/table_demo.py) + +![](http://matplotlib.org/_images/table_demo1.png) + +## 散点图示例 + +`scatter()`命令使用(可选的)大小和颜色参数创建散点图。 此示例描绘了 Google 股票价格的变化,标记的尺寸反映了交易量,并且颜色随时间变化。 这里,ALPHA 属性用于制作半透明圆形标记。 + +[源代码](http://matplotlib.org/mpl_examples/pylab_examples/scatter_demo2.py) + +![](http://matplotlib.org/_images/scatter_demo21.png) + +## 滑块示例 + +Matplotlib 拥有基本的 GUI 小部件,它们独立于您正在使用的图形用户界面,允许您编写 GUI 交叉图形和小部件。 请参阅[`matplotlib.widgets`](http://matplotlib.org/api/widgets_api.html#module-matplotlib.widgets)和[小部件示例](http://matplotlib.org/examples/widgets/index.html)。 + +[源代码](http://matplotlib.org/mpl_examples/widgets/slider_demo.py) + +![](http://matplotlib.org/_images/slider_demo.png) + +## 填充示例 + +`fill()`命令可以绘制填充曲线和多边形: + + +[源代码](http://matplotlib.org/mpl_examples/lines_bars_and_markers/fill_demo.py) + +![](http://matplotlib.org/_images/fill_demo2.png) + +感谢 Andrew Straw 添加了这个函数。 + +## 日期示例 + +您可以绘制日期数据与主要和次要刻度,以及用于二者的自定义刻度格式化器。 + +[源代码](http://matplotlib.org/mpl_examples/api/date_demo.py) + +![](http://matplotlib.org/_images/date_demo3.png) + +详细信息和用法请参阅[`matplotlib.ticker`](http://matplotlib.org/api/ticker_api.html#module-matplotlib.ticker)和[`matplotlib.dates`](http://matplotlib.org/api/dates_api.html#module-matplotlib.dates)。 + +## 金融图表 + +您可以通过结合 matplotlib 提供的各种绘图函数,布局命令和标签工具来创建复杂的金融图表。 以下示例模拟 ChartDirector 中的一个财务图: + +[源代码](http://matplotlib.org/mpl_examples/pylab_examples/finance_work2.py) + +![](http://matplotlib.org/_images/finance_work21.png) + +## 地图示例 + +Jeff Whitaker 的 [Basemap](http://matplotlib.org/mpl_toolkits/index.html#toolkit-basemap) 附加工具包可以在许多不同的地图投影上绘制数据。 此示例展示了如何在直角投影上绘制轮廓,标记和文本,以 NASA 的“蓝色大理石”卫星图像作为背景。 + +[源代码](http://matplotlib.org/pyplots/plotmap.py) + +## 对数绘图 + +`semilogx()`,`semilogy()`和`loglog()`函数简化了对数绘图的创建。 + +[源代码](http://matplotlib.org/mpl_examples/pylab_examples/log_demo.py) + +![](http://matplotlib.org/_images/log_demo2.png) + +## 极轴绘图 + +`polar()`命令生成极轴绘图。 + +[源代码](http://matplotlib.org/mpl_examples/pylab_examples/polar_demo.py) + +![](http://matplotlib.org/_images/polar_demo1.png) + +## 图例 + +`legend()`命令使用 MATLAB 兼容的图例布局命令自动生成图形图例。 + +[源代码](http://matplotlib.org/mpl_examples/api/legend_demo.py) + +![](http://matplotlib.org/_images/legend_demo6.png) + +感谢 Charles Twardy 编写了图例命令的输入。 + +## 数学公式示例 + +下面是 matplotlib 内部数学公式引擎现在支持的许多 TeX 表达式的示例。 `mathtext`模块使用 [freetype2](http://www.freetype.org/) 和 BaKoMa 或 [STIX](http://www.stixfonts.org/) 现代字体提供 TeX 风格的数学表达式。 其他详细信息请参阅[`matplotlib.mathtext`](http://matplotlib.org/api/mathtext_api.html#module-matplotlib.mathtext)模块。 + +[源代码](http://matplotlib.org/mpl_examples/pylab_examples/mathtext_examples.py) + +![](http://matplotlib.org/_images/mathtext_examples_01_001.png) + +Matplotlib 的`mathtext`基础结构是一个独立的实现,不需要 TeX 或计算机上安装的任何外部软件包。 请参阅[编写数学表达式](http://matplotlib.org/users/mathtext.html#mathtext-tutorial)教程。 + +## TeX 原生渲染 + +虽然 matplotlib 的内部数学渲染引擎相当强大,但有时你还是需要 TeX。Matplotlib 支持带有 usetex 选项的 TeX 外部字符串渲染。 + +[源代码](http://matplotlib.org/pyplots/tex_demo.py) + +![](http://matplotlib.org/_images/tex_demo1.png) + +## EEG 示例 + +您可以将 matplotlib 嵌入到 pygtk,wx,Tk,FLTK 或 Qt 应用程序中。 这是一个名为 [pbrain](http://github.com/nipy/pbrain) 的 EEG 查看器的屏幕截图。 + +![](http://matplotlib.org/_images/eeg_small.png) + +下轴使用`specgram()`绘制其中一个 EEG 通道的频谱图。 + +有关将 matplotlib 嵌入不同工具包的示例,请参阅: + ++ [`user_interfaces`示例代码:`embedding_in_gtk2.py`](http://matplotlib.org/examples/user_interfaces/embedding_in_gtk2.html#user-interfaces-embedding-in-gtk2) ++ [`user_interfaces`示例代码:`embedding_in_wx2.py`](http://matplotlib.org/examples/user_interfaces/embedding_in_wx2.html#user-interfaces-embedding-in-wx2) ++ [`user_interfaces`示例代码:`mpl_with_glade.py`](http://matplotlib.org/examples/user_interfaces/mpl_with_glade.html#user-interfaces-mpl-with-glade) ++ [`user_interfaces`示例代码:`embedding_in_qt4.py`](http://matplotlib.org/examples/user_interfaces/embedding_in_qt4.html#user-interfaces-embedding-in-qt4) ++ [`user_interfaces`示例代码:`embedding_in_tk.py`](http://matplotlib.org/examples/user_interfaces/embedding_in_tk.html#user-interfaces-embedding-in-tk) + +## XKCD 风格的手绘图 + +matplotlib 支持`xkcd`风格的绘图。 + +[源代码](http://matplotlib.org/mpl_examples/showcase/xkcd.py) + +![](http://matplotlib.org/_images/xkcd_001.png) + +![](http://matplotlib.org/_images/xkcd_011.png) -- GitLab