python 散点图 分类_Python | 分类图
python 散點圖 分類
Visualizing different variables is also a part of basic plotting. Such variables can have different classes, for example, numerical or a category. Matplotlib has an important feature of Categorical Plotting. We can plot multiple categorical variables within different types of plots such as line, dot, bar, scatter, etc.
可視化不同的變量也是基本繪圖的一部分。 這樣的變量可以具有不同的類別,例如,數(shù)值或類別。 Matplotlib具有分類繪圖的重要功能。 我們可以在不同類型的圖中繪制多個類別變量,例如線,點,條,散點圖等。
Following are some examples of categorical plotting:
以下是分類繪圖的一些示例 :
Syntax:
句法:
matplotlib.pyplot.figure(figsize=(4,3))#figsize(float, float) width, height in inches.示例1:線圖 (Example 1: Line Plot)
示例2:條形圖 (Example 2: Bar Plot)
示例3:點圖 (Example 3: Dot Plot)
用于分類繪圖的Python代碼 (Python code for categorical plotting)
# Data Visualization using Python # Categorical Plottingimport matplotlib.pyplot as pltnames = ['Rabhes', 'Grpsh J.', 'John C. Dave'] values = [45646, 75640, 42645]# example 1 plt.figure() plt.plot(names, values, color='y') plt.ylabel('Income') plt.title('Income Comparison') plt.show()# example 2 plt.figure() plt.bar(names, values, color='y') plt.ylabel('Income') plt.title('Income Comparison') plt.show()# example 3 plt.figure() plt.plot(names, values, 'or') plt.ylabel('Income') plt.title('Income Comparison') plt.show()Output:
輸出:
Output is as figure翻譯自: https://www.includehelp.com/python/categorical-plotting.aspx
python 散點圖 分類
總結(jié)
以上是生活随笔為你收集整理的python 散点图 分类_Python | 分类图的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: dir函数_PHP dir()函数与示例
- 下一篇: Python | 如何创建模块(模块示例