简体   繁体   中英

How To plot a discrete categorical dataframe

I am trying to plot a graph like这个 of the CSV file drive link in python. I looked upon alot of tutorials of seaborn and matplotlib but can't figure out a way to do this. I also tried iterating the rows still didn't work. Any help will be highly appreciated. sample Dataframe:

clr CYS ASP SER GLN LYS ILE PRO
2rh1_0 1 0 0 0 0 1 1
2rh1_1 0 0 0 0 0 1 0
2rh1_2 0 0 0 0 1 0 0
3D4S_0 1 0 1 0 1 0 0

You're looking for a scatter plot like this:

import matplotlib.pyplot as plt

data = {'apples': 'sweet', 'oranges': 'both', 'lemons': 'sour', 'limes': 'sour', 'strawberries': 'sweet'}
names = list(data.keys())
values = list(data.values())

plt.scatter(data.keys(), data.values())
plt.show()

散点图

Note: the data clearly doesn't have to be in a dictionary, I'm passing it as two iterables when calling plt.scatter , so it could be in two lists, a list of tuples, etc.

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