matplotlib.pyplot provides a number of different functions that can be used to plot and visualize our data. It also gives a free hand to do different operations with a plot such as annotations, marking, etc. In this article, we are going to learn a very basic plot type and how to label its axis and furthermore will add the Figure title.
matplotlib.pyplot提供了许多不同的功能,可用于绘制和可视化我们的数据。 它还使您可以自由地对图形进行不同的操作,例如注释,标记等。在本文中,我们将学习一种非常基本的图形类型以及如何标注其坐标轴,此外还将添加Figure标题。
Plotting using a single array automatically puts it on the y-axis. So adding two arrays in order (x-axis, y-axis) can produce our desired plot. One example is shown in figure 2.
使用单个数组进行绘图会自动将其放置在y轴上。 因此,按顺序添加两个数组(x轴,y轴)可以生成我们想要的图。 图2显示了一个示例。
Python代码演示Matplotlib中的Pyplot示例 (Python code to demonstrate example of Pyplot in Matplotlib)
# Data Visualization using Python
# Basics of Plotting
import matplotlib.pyplot as plt
# plotting using plt.pyplot()
plt.plot([4,7,3,6,1,8,9,2,3])
# axis labeling
plt.xlabel('numbers')
plt.ylabel('values')
# figure name
plt.title('Plotting Basics')
##########################################
# plotting using plt.pyplot() Figure 2
plt.plot([1,7,3,6],[1,8,9,3])
# axis labeling
plt.xlabel('numbers')
plt.ylabel('values')
# figure name
plt.title('Plotting Basics : Figure 2')
翻译自: https://www.includehelp.com/python/pyplot-in-matplotlib.aspx