python点线图
A mixture of dot and line plot is called a Dot-Line plot. Each dot is connected through a line and it is the next version of the line plot. It maintains the discrete property of the points and also represents the correlation between consecutive points. It makes data visualization much better than an individual line or dot plot. Matplotlib provides this feature and with the following examples, we can better understand the implementation.
点线图的混合称为点线图。 每个点通过一条线连接,这是该线图的下一个版本。 它既保持了点的离散特性,又代表了连续点之间的相关性。 它使数据可视化远胜于单个线或点图。 Matplotlib提供了此功能,并通过以下示例,我们可以更好地理解实现。
1)标准点线图 (1) Standard Dot-Line Plot)
Syntax:
句法:
plt.plot(x, y,'o-')
x - names/numeric distribution
x-名称/数字分布
y - length of the bar
y-钢筋的长度
o- - instruction for dot-line
o--虚线说明
2)点线较小的点线图 (2) Dot-Line Plot with Smaller Dot)
Syntax:
句法:
plt.plot(x, y,'o-')
x - names/numeric distribution
x-名称/数字分布
y - length of the bar
y-钢筋的长度
.- - instruction for dot-line with small dot
.--带小点的虚线说明
3)不同颜色的点线图 (3) Dot-Line Plot with Different Color)
Syntax:
句法:
plt.plot(x, y,'o-')
x - names/numeric distribution
x-名称/数字分布
y - length of the bar
y-钢筋的长度
g.- - instruction for dot-line with small dot green color
g。--小点绿色的虚线说明
虚线绘图的Python代码 (Python code for dot-line plotting)
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0.0, 5.0)
y = x*x
# default Plot
plt.subplot(2, 1, 1)
plt.plot(x, y, 'o-')
plt.title('Dot-Line Plot (1)')
plt.ylabel('Square')
plt.xlabel('numbers')
plt.show()
# Smaller dot
plt.subplot(2, 1, 2)
plt.plot(x, y, '.-')
plt.title('Dot-Line Plot (2): Smaller Dot')
plt.xlabel('numbers')
plt.ylabel('Square')
plt.show()
#colour Change
plt.subplot(2, 1, 2)
plt.plot(x, y, 'g.-')
plt.title('Dot-Line Plot (3): Colour Change')
plt.xlabel('numbers')
plt.ylabel('Square')
plt.show()
Output:
输出:
Output is as figure
翻译自: https://www.includehelp.com/python/dot-line-plotting.aspx
python点线图