Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Plot a lineal graph with columns diverging from main column

Hello I want to create a lineal graph of this Dataframe

A  B  C  D
2  1  5  7
1  4  3  1

I would like to know the way to create a line graph with this idea:

Using A as Main Colum

So I want a resulting line graph with this values

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

A  B  C  D
0  -1 3  5
0  3  2  0

The main idea I have is to duplicate the DF and do something like this

df2=df
df2["B"]= df2["B"]-df2["A"]
df2["C"]= df2["C"]-df2["A"]
df2["D"]= df2["D"]-df2["A"]
df2["A"]=df2["A"]-df2["A"]

df2.plot()

Do you have another way to set this graph faster?

>Solution :

What about:

df2 = df.sub(df['A'], axis=0)

output:

   A  B  C  D
0  0 -1  3  5
1  0  3  2  0
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading