Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to plot individual scatter plots from a csv paired with the same columns
My x-axis is 'Date' and y-axis is 'Column variable':
There are 14 individual sites and 21 columns

My csv looks like:
Date ID Aluminium Antimony....
30/04/2019 C2105 172 0.0025
28/05/2019 C2105 4.16 0.0005
25/06/2019 C2105 11.8 0.0005
29/07/2019 C2105 38.3 0.001
28/09/2019 C2105 0.54 0.0025
13/03/2019 C3505 172 0.0025
28/06/2019 C3505 4.16 0.0005
09/04/2019 C3505 11.8 0.0005
29/07/2019 C3505 38.3 0.001
28/09/2019 C3505 0.54 0.0025

So what I need is:
1 x scatterplot for C2105 for Aluminium
1 x scatterplot for C2105 for Antimony etc.
This will be repeated for each additional site.

I hope this makes sense ?

What I have tried:

data = pd.read_csv('GW_Water_Quality__ Total Metals by ICP-MS.csv')
x_col = "Date"
y_columns = ["Aluminium", "Antimony", "Arsenic", "Beryllium", "Barium",
             "Cadmium",	"Chromium",	"Cobalt",	"Copper",	"Lead",	"Manganese",
             "Molybdenum",	"Nickel",	"Selenium", "Silver", "Strontium",	"Uranium",
             "Vanadium", "Zinc", "Boron",	"Iron"]

for y_col in y_columns:

    figure = plt.figure
    ax = plt.gca()
    ax.scatter(data[x_col], data[y_col])
    ax.set_title("{} vs {}".format(x_col, y_col))

Richard MacCutchan 29-Sep-22 3:40am    
You forgot to ask a question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900