上图来自BIGBIO,如果你是临摹大神,你可以纯手工画一个,但如果你不是怎么办呢?
首先,你要知道这三种图的名字
树图
百度首选画法为python 的 pyecharts包
newdata处理成这种格式
[{"value": 2, "name": "TT-ts", "children": [{"name": "IMCS-V2-MRG", "value": 1}, {"name": "Text2DT", "value": 1}]},
{"value": 2, "name": "TT-ds", "children": [{"name": "meqsum", "value": 1}, {"name": "multi_xscience", "value": 1}]},
{"value": 2, "name": "TP-te", "children": [{"name": "scitail", "value": 1}, {"name": "mediqa_rqe", "value": 1}]}]
c = (
TreeMap()
.add(
series_name="aaa",
data=newdata,
levels=[
opts.TreeMapLevelsOpts(
treemap_itemstyle_opts=opts.TreeMapItemStyleOpts(
border_color="#555", border_width=4, gap_width=4
)
),
opts.TreeMapLevelsOpts(
color_saturation=[0.3, 0.6],
treemap_itemstyle_opts=opts.TreeMapItemStyleOpts(
border_color_saturation=0.7, gap_width=2, border_width=2
),
),
opts.TreeMapLevelsOpts(
color_saturation=[0.3, 0.5],
treemap_itemstyle_opts=opts.TreeMapItemStyleOpts(
border_color_saturation=0.6, gap_width=1
),
),
opts.TreeMapLevelsOpts(color_saturation=[0.3, 0.5]),
],
)
.set_global_opts(title_opts=opts.TitleOpts(title="数据分布图"))
.render("层级矩阵树图2.html")
)
效果如下
直方图/水平条
如果采用excel作直方图,只会导致相同颜色不能靠着一起,或者说同一图例的数据条分隔开.如图所示
当然wps也没有相同颜色靠着一起的功能
这时候可以采用python的matplotlib包
import pandas as pd
df = pd.read_excel('temp.xlsx') #读取xlsx中第一个sheet
test_data=[]
names = df.iloc[:,[0]].values
dataclass=df.iloc[:,[1]].values
datavalue=df.iloc[:,[2]].values
data1 = df.iloc[0].values
data={}
for idx,name in enumerate(names):
sample={}
data1 = df.iloc[idx].values
sample['name']=data1[0]
sample['value']=int(data1[2])
if data1[1] not in data.keys():
data[data1[1]]=[]
data[data1[1]].append(sample)
import matplotlib.pyplot as plt
y=[]
precolors = plt.cm.tab20.colors
colors=[]
lines=[]
lable=[]
for idx,key in enumerate(data.keys()):
lable.append(key)
line=plt.Line2D([0], [0], color=precolors[idx], lw=4)
lines.append(line)
for xi in data[key]:
colors.append(precolors[idx])
y.append(xi['value'])
x = list(range(len(y)))
plt.figure(figsize=(20,8))
plt.legend(lines, lable,loc='best')
plt.barh(x, y, color=colors,log = True)
plt.yticks([])
# set ticks at the mean positions of the bars
plt.margins(x=0.001) # less empty space at the left and right of the bars
plt.show()
这里有一个小细节坐标轴设置为log形式,因为数据分布并不均衡,若是均值的坐标轴就会只能看见1到2条数据直线
填充气泡图
这个图很简单,嫌弃下面步骤复杂的人可以自己用画版画.
进入软件后点击数据,新建数据源,excel格式,选择自己的excel文件
如图已经导入数据
点击工作表1开始数据可视化,我这里用4做示范因为BIGBIO气泡图以任务为计数条件,因此右键任务,选择转换为度量,此时发现可以选择气泡图,选择后将属性调整如图所示
下面讲一下这个标记框具体操作方法
如图点击条目前面的标记可以切换标记类型,这五个类型分别决定颜色区分的标准,大小区分的标准,图上显示的文字,详细信息,鼠标放上去显示的信息,然后就明白我为什么这么设置了
细节
如果你标签显示不全,除了调小字号也可以尝试关闭自动换行
单击这个强制显示标签
勾选允许覆盖
在前面的图中可以看到这个软件实际上是可以显示我们所需的全部三种图的,
因此我们在这将上面两个图实现一下,标志和行列设置如图
在仪表容器中将三幅图组合起来
完成