# python数据可视化案例——平行坐标系(使用pyecharts或pandas)

二、平行坐标图的解读

（1）折线走势“陡峭”与“低谷”只是表示在该属性上属性值的变化范围的大小，对于标签分类不具有决定意义，但是“陡峭“的属性上属性值间距较大，视觉上更容易区分出不同的标签类别

（2）标签的分类主要看相同颜色的折线是否集中，若在某个属性上相同颜色折线较为集中，不同颜色有一定的间距，则说明该属性对于预测标签类别有较大的帮助

（3）若某个属性上线条混乱，颜色混杂，则较大可能该属性对于标签类别判定没有价值
————————————————

python数据可视化代码和案列

```import matplotlib.pyplot as plt
import pandas as pd
from pandas.tools.plotting import parallel_coordinates

data = pd.read_csv(‘E:/ProgramData/Anaconda3/pkgs/pandas-0.23.0-py36h830ac7b_0/Lib/site-packages/pandas/tests/data/iris.csv‘)
data_1 =data[[‘Name‘,‘SepalLength‘, ‘SepalWidth‘, ‘PetalLength‘, ‘PetalWidth‘]]

parallel_coordinates(data_1,‘Name‘)
plt.legend(loc=‘upper center‘, bbox_to_anchor=(0.5,-0.1),ncol=3,fancybox=True,shadow=True)
plt.show()```

```from pyecharts import options as opts
from pyecharts.charts import Page, Parallel

data = [
[1, 91, 45, 125, 0.82, 34],
[2, 65, 27, 78, 0.86, 45],
[3, 83, 60, 84, 1.09, 73],
[4, 109, 81, 121, 1.28, 68],
[5, 106, 77, 114, 1.07, 55],
[6, 109, 81, 121, 1.28, 68],
[7, 106, 77, 114, 1.07, 55],
[8, 89, 65, 78, 0.86, 51, 26],
[9, 53, 33, 47, 0.64, 50, 17],
[10, 80, 55, 80, 1.01, 75, 24],
[11, 117, 81, 124, 1.03, 45],
]
c = (
Parallel()
.add_schema(
[
{"dim": 0, "name": "data"},
{"dim": 1, "name": "AQI"},
{"dim": 2, "name": "PM2.5"},
{"dim": 3, "name": "PM10"},
{"dim": 4, "name": "CO"},
{"dim": 5, "name": "NO2"},
]
)
.add("parallel", data)
.set_global_opts(title_opts=opts.TitleOpts(title="Parallel-基本示例"))
)

c.render("平行坐标系图1.html")

```

```from pyecharts import options as opts
from pyecharts.charts import Page, Parallel

data = [
[1, 91, 45, 125, 0.82, 34, 23, "良"],
[2, 65, 27, 78, 0.86, 45, 29, "良"],
[3, 83, 60, 84, 1.09, 73, 27, "良"],
[4, 109, 81, 121, 1.28, 68, 51, "轻度污染"],
[5, 106, 77, 114, 1.07, 55, 51, "轻度污染"],
[6, 109, 81, 121, 1.28, 68, 51, "轻度污染"],
[7, 106, 77, 114, 1.07, 55, 51, "轻度污染"],
[8, 89, 65, 78, 0.86, 51, 26, "良"],
[9, 53, 33, 47, 0.64, 50, 17, "良"],
[10, 80, 55, 80, 1.01, 75, 24, "良"],
[11, 117, 81, 124, 1.03, 45, 24, "轻度污染"],
[12, 99, 71, 142, 1.1, 62, 42, "良"],
[13, 95, 69, 130, 1.28, 74, 50, "良"],
[14, 116, 87, 131, 1.47, 84, 40, "轻度污染"],
]
c = (
Parallel()
.add_schema(
[
opts.ParallelAxisOpts(dim=0, name="data"),
opts.ParallelAxisOpts(dim=1, name="AQI"),
opts.ParallelAxisOpts(dim=2, name="PM2.5"),
opts.ParallelAxisOpts(dim=3, name="PM10"),
opts.ParallelAxisOpts(dim=4, name="CO"),
opts.ParallelAxisOpts(dim=5, name="NO2"),
opts.ParallelAxisOpts(dim=6, name="CO2"),
opts.ParallelAxisOpts(
dim=7,
name="等级",
type_="category",
data=["优", "良", "轻度污染", "中度污染", "重度污染", "严重污染"],
),
]
)
.add("parallel", data)
.set_global_opts(title_opts=opts.TitleOpts(title="Parallel-Category"))
)

c.render("平行坐标系图2.html")
```

pyecharts画图更多请查看官方文档：

http://pyecharts.org/#/zh-cn/basic_charts?id=parallel%EF%BC%9A%E5%B9%B3%E8%A1%8C%E5%9D%90%E6%A0%87%E7%B3%BB

python数据可视化案例——平行坐标系(使用pyecharts或pandas)

(0)
(0)

© 2014 mamicode.com 版权所有 京ICP备13008772号-2