2⃣️. 数据图片性质

作者: Joeylee1990s | 来源:发表于2018-10-25 14:02 被阅读3次

1. Markers and line styles

plt.plot(X, Y, '<format>', ...)

controlling color:

b(blue); c(cyan); g(green); k(black); m(magenta); r(red); w(white); y(yellow).

Specifying styles in multiline plots---specifying all the lines in a single function call

plt.plot(x1, y1, fmt1, x2, y2, fmt2, ...)

Controlling line styles

'-'solid line ; '--'dashed line;  '-.' dash-dot line;  ':' dotted line.

controlling marker styles---several markers can be used in Matplotlb;

In the following example, we try to group up all the customization available for colors, lines, and markers in the following way:

y = np.arange(1, 3, 0.3)

plt.plot(y, 'cx--', y+1, 'mo:', y+2, 'kp-.')

2. Finer control with keyword arguments

plot() is a really rich function, and there are some keyword arguments to configure colors, markers, and line styles:

keyword arguments !!!

3. Handling X and Y axis

Matplotlib provides two basic functions to manage them—xticks() and yticks(). They behave in the same way, so the description for one function will apply to the other too.

4. Plot types

1) Histogram charts---Histogram charts are a graphical display of frequencies, represented as bars. They show what portion of the dataset falls into each category, usually specified as non-overlapping intervals. Matplotlib calls those categories bins.

By default, hist() uses a bin value of 10 (so only ten categories, or bars, are computed), but we can customize it, either by passing an additional parameter, for example, in hist(y, <bins>), or using the bin keyword argument as hist(y, bin=<bins>).

2) Error bar charts

Using the errorbar() function, Matplotlib allows us to create such a graph type.

plt.errorbar(x, y, yerr=e1, fmt='.-');


3) Scatter plots

A scatter plot is often used to identify potential association between two variables, and it's often drawn before working on a fitting regression function. It gives a good visual picture of the correlation, in particular for nonlinear relationships. Matplotlib provides the scatter() function to plot X versus Y unidimensional array of the same length as scatter plot.

4) Polar charts

A polar system is a two-dimensional coordinate system, where the position of a point is expressed in terms of a radius and an angle. This system is used where the relationship between two points is better expressed using those information. The angular coordinate can be expressed either in radians or in degrees. Though, Matplotlib uses degrees. The polar() Matplotlib function plots polar charts. Its parameters are two lists (of the same length)—theta for the angular coordinates and r for the radial coordinates.

There are two functions to control the radial and the angular grids: rgrid() and thetagrid() functions respectively.

theta = np.arange(0., 2., 1./180.)*np.pi

r = np.abs(np.sin(5*theta) - 2.*np.cos(theta))

plt.polar(theta, r);    #1

plt.thetagrids(range(45, 360, 90));  #2

plt.rgrids(np.arange(0.2, 3.1, .7), angle=0);  #3

5. Text inside figure, annotations, and arrows

1) adding text inside the figure

plt.text(x, y, text)

2) adding annotations

The annotate() function provides functionality to make annotation easy. In annotation, we have to consider two points—the graph point we want to annotate (represented by an xy keyword argument) and the plot position where we want to place the annotation text (represented by xytext). Both are expressed in an (x,y) format in data coordinate positions; Moreover, there is an additional argument to specify the arrow properties, that's the fundamental difference between text() and annotate(). We connect the annotation text to the annotated point with an arrow.

plt.plot(y);

plt.ylim(ymax=35);

plt.annotate('this spot must really\nmean something', xy=(6, 30), xytext=(8, 31.5), arrowprops=dict(facecolor='black', shrink=0.05));

Also note that we had to use ylim() to adjust the Y limits, as annotate() does not do it automatically.

3) adding an arrow

Matplotlib provides an arrow() function. It takes the coordinates of the arrow origin (x,y), and the delta distance (dx, xy), the distance at which the head is to be placed. This implies that the arrow starts at (x,y) and ends at (x + dx, y + dy)

plt.arrow(x, y, dx, dy)

Sadly, this function is quite hard to use and presents several difficulties.

相关文章

  • 2⃣️. 数据图片性质

    1. Markers and line styles plt.plot(X, Y, ' ', ...) contr...

  • 切图

    图片切图命名 图性质_ 功能相关描述_ 图片描述(可无)_ 状态说明(可无)@2X.png 例如:bg_book...

  • Android媒体数据库操作

    1.获取媒体数据所有的图片、音频、视频、文件;2.分页获取媒体数据的图片、音频、视频、文件;3.删除媒体数据的图片...

  • 2018-06-26

    一、IIS安装 2.图片 二、在IIS上系统网站以及登录 2.图片 三、连接数据库 2..图片

  • 皮肤性质2

    干性肤质 干性肌肤比中性肌肤相对皮脂腺较少,而且皮脂和汗分泌比较少,这样的皮肤它的皮脂膜不易形成,毛孔细小,很少有...

  • css性质(2)

    1、font-family设置字体类型 h1{ font-family:“黑体”; } ...

  • iOS小游戏——连连看(二)地图初始化

    1、生成地图数据 2、把数据换成图片 LLKElement类: 效果图:

  • 机器学习2(算法,基础)

    算法是核心,数据和计算是基础 数据类型1、离散数据类型2、连续数据类型图片.png 机器学习算法分类图片.png监...

  • 图神经网络:GCN原理学习笔记

    摘要:图神经网络,GCN 图数据的特征性质 图像数据是一种特殊的图数据,图像数据是标准的2D网格结构图数据。图像数...

  • Android图片存取数据库

    1、存图片路径2、存图片二进制(sqllite blob的数据类型)3、存图片Uri

网友评论

    本文标题:2⃣️. 数据图片性质

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