0

I am trying to plot a graph like this 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
  • Please post your best coding attempt and sample data (not as external link that can break for future readers) so we can help in your learning curve. StackOverflow is not a free code writing service. – Parfait Dec 24 '20 at 22:48
  • Hey @Parfait Thank you for your comment, but the work I am doing is confidential, and will have to share the whole code to get this data frame, also every user will have to download 529 files first to get this data frame. I can't share the whole code here until my mentor allows me (will gladly share the code once we make the whole data public). Although I will not disable the drive link I shared and will also post the sample data frame in the question. – mohit kushwah Dec 25 '20 at 11:50
  • Please see [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). We understand the confidential, proprietary nature of data. You can set up sample data that resembles actual data. – Parfait Dec 25 '20 at 17:59
  • Thanks for the reference material. I guess the sample dataframe now makes more sense. Although I found the answer to my question here [link](https://stackoverflow.com/questions/22255677/plotting-a-dictionary-with-multiple-values-per-key) in case anyone needs this. – mohit kushwah Dec 26 '20 at 09:18

1 Answers1

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()

a scatter plot

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.

Grismar
  • 27,561
  • 4
  • 31
  • 54
  • Hey @Grismar, Thank you for your answer. I have a question though, my database is not one-one related, like in your data if "apples":["sweet","both"], "orange":["sour","both"] how can I plot in this situation. My data is more similar to this one, it has multiple relations with a single x value – mohit kushwah Dec 25 '20 at 11:37
  • Hello Thank you for your responses, I found https://stackoverflow.com/questions/22255677/plotting-a-dictionary-with-multiple-values-per-key this and It solves my issue. Thank you again. – mohit kushwah Dec 25 '20 at 11:43