- Python Data Analysis(Second Edition)
- Armando Fandango
- 169字
- 2021-07-09 19:04:03
Visualizing data using Matplotlib
We shall learn about visualizing the data in a later chapter. For now, let's try loading two sample datasets and building a basic plot. First, install the sklearn library from which we shall load the data using the following command:
$ pip3 install scikit-learn
Import the datasets using the following command:
from sklearn.datasets import load_iris from sklearn.datasets import load_boston
Import the Matplotlib plotting module:
from matplotlib import pyplot as plt %matplotlib inline
Load the iris
dataset, print the description of the dataset, and plot column 1 (sepal length) as x
and column 2 (sepal width) as y
:
iris = load_iris() print(iris.DESCR) data=iris.data plt.plot(data[:,0],data[:,1],".")
The resulting plot will look like the following image:

Load the boston dataset, print the description of the dataset and plot column 3 (proportion of non-retail business) as x
and column 5 (nitric oxide concentration) as y
, each point on the plot marked with a + sign:
boston = load_boston() print(boston.DESCR) data=boston.data plt.plot(data[:,2],data[:,4],"+")
The resulting plot will look like the following image:

- 測試驅動開發:入門、實戰與進階
- Python數據可視化:基于Bokeh的可視化繪圖
- Vue.js前端開發基礎與項目實戰
- Rust編程從入門到實戰
- Java加密與解密的藝術(第2版)
- Visual Basic程序設計教程
- C語言程序設計
- Python 3破冰人工智能:從入門到實戰
- 微信小程序開發解析
- 焊接機器人系統操作、編程與維護
- HTML5+CSS3 Web前端開發技術(第2版)
- Frank Kane's Taming Big Data with Apache Spark and Python
- Python3.5從零開始學
- Python:Deeper Insights into Machine Learning
- Learning iOS Security