简体   繁体   中英

How to plot several categorical features in a single plot in python?

I have a pandas data frame with each row of data containing an id and several binary data that has only two options 0 or 1.

id, feat1, feat2, feat3, feat4
aa, 0, 1, 1, 0
ab, 1, 0, 1, 0
ac, 0, 0, 1, 0

and etc

I want to be able to visualise this with id on y-axis, and all features on x axis.. with a dot representing 1 and no dot representing 0.. almost like the above dataframe but in plot form

You may consider the heatmap :

import seaborn as sns
ax = sns.heatmap(df.set_index('id'), annot = True)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM