4⃣️. 二维图设计

作者: Joeylee1990s | 来源:发表于2018-10-26 22:18 被阅读6次

Contour plots and image plotting

Contour lines (also known as level lines or isolines) for a function of two variables are curves where the function has constant values. f(x, y) = L.

contour(matrix, N)

There is also a similar function that draws a filled contours plot, contourf() function. contourf() fills the spaces between the contours lines with the same color progression used in the contour() plot:

fig = plt.figure()

matr = np.random.rand(21, 31)

ax1 = fig.add_subplot(121)

ax1 = plt.contour(matr)

ax2 = fig.add_subplot(122)

ax2 = plt.contourf(matr)

plt.colorbar()

Labeling the level lines is important in order to provide information about what levels were chosen for display; clabel() does this by taking as input a contour instance, as returned by a previous contour() call:

x = np.arange(-2,2,0.01)

y = np.arange(-2,2,0.01)

X, Y = np.meshgrid(x, y)

ellipses = X*X/9 + Y*Y/4 - 1

cs = plt.contour(ellipses)

plt.clabel(cs)

Here, we draw several ellipses and then call clabel() to display the selected levels. We used the NumPy meshgrid() function to get the coordinate matrices, X and Y, from the two coordinate vectors, x and y.

Imaging plotting

imread() reads an image from a file and converts it into a NumPy array;

imshow() takes an array as input and displays it on the screen:

f = plt.imread('/path/to/image/file.ext')

plt.imshow(f)

Matplotlib can only read PNG files natively, but if the Python Imaging Library (usually known as PIL) is installed, then this library will be used to read the image and return an array (if possible).

imshow() can plot any 2D sets of data and not just the ones read from image files. For example, let's take the ellipses code we used for contour plot and see what imshow() draws:

x = np.arange(-2,2,0.01)

y = np.arange(-2,2,0.01)

X, Y = np.meshgrid(x, y)

ellipses = X*X/9 + Y*Y/4 - 1

cs = plt.imshow(ellipses)
plt.colorbar()

This example creates a full spectrum of colors starting from deep blue of the image center, slightly turning into green, yellow, and red near the image corners.

相关文章

  • 4⃣️. 二维图设计

    Contour plots and image plotting Contour lines (also know...

  • 作品集

    1、icon图 2、banner设计 3、插画设计 4、界面设计

  • 作品集

    1、icon图 2、banner设计 3、插画设计 4、界面设计

  • axure原型设计之二维码扫描框

    效果图:axure原型设计之二维码扫描框 自从二维码流行起来之后,二维码成了移动端的一种很关键的入口,随时随地只需...

  • 大话软件工程:需求分析与软件设计(十二)

    第4篇设计工程——详细设计 第12章架构的详细设计 业务架构的成果中,拓扑图和分层图用于顶层的规划,框架图和分解图...

  • 二维码

    1. 生成二维码 2.生成条形码 3.扫描二维码/条形码 4.相册选择识别二维码/条形码 5.长按识别二维码 给图...

  • 思维导图是如何创建二维图

    XMind现在设计了一种新的思维导图结构——二维图,也就是矩阵图。这种结构的思维导图通常被我们用来对复杂的因素进行...

  • 室内设计CAD施工图纸

    CAD施工图纸 平面设计类 1目录 2图例 3原始结构图 4拆切墙体图 5平面设计图 6顶面设计图 7顶面尺寸图 ...

  • 601. 摊平二维向量

    描述 设计一个迭代器来实现摊平二维向量的功能 样例 给一个二维向量[ [1,2], [3], [4,5,6] ]通...

  • CoreImage之生成二维码

    生成二维码的步骤 学习自小码哥 1、创建生成二维码的滤镜实例 2、初始化滤镜 3、输入数据 4、获取输出高清图 -...

网友评论

    本文标题:4⃣️. 二维图设计

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