Matplotlib cmap sample
The mathtext module provides TeX style mathematical expressions using FreeType and the DejaVu, BaKoMa computer modern, or STIX fonts. Apart from the built-in colormaps defined in the colormaps reference (and their reversed maps, with '_r' appended to their name), custom colormaps can also be defined. matplotlib教程学习笔记. # plot the sample fig = plt.figure plt.imshow(image, cmap='gray_r') plt.show() In order to plot multiple digits, you can use a “for” loop, along with matplotlib’s subplots functionality. See the matplotlib… First, getting a named colormap, most of which are listed in Choosing Colormaps in Matplotlib requires the use of matplotlib.cm.get_cmap, which returns a matplotlib.colors.ListedColormap object. Matplotlib has a number of built-in colormaps accessible via matplotlib.cm.get_cmap.There are also external libraries like and that have many extra colormaps. Below is a sampling of the many TeX expressions now supported by Matplotlib's internal mathtext engine. Choosing Colormaps in Matplotlib¶. Getting colormaps and accessing their values¶. Here we briefly discuss how to choose between the many options. 这部分给出一些简单的示例。 Line Plot t = np.arange(0.0, 2.0, 0.01) s = 1 + np.sin(2 * np.pi * t) fig, ax = plt.subplots() ax.plot(t, s) ax.set(xlabel='time (s)', ylabel='voltage (mV)', title='About as simple as it gets, folks') #设置一些属性 ax.grid() #显示网格 #fig.savefig("test.png") 保存图片在当前目录下 plt.show() Kite is a free autocomplete for Python developers. Code faster with the Kite plugin for your code editor, featuring Line-of-Code Completions and cloudless processing.
Example. The key is the matplotlib.cm module..