0

I am new to data plotting, matplotlib or sns library. There is a

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

y = np.random.rand(10,4)
y[:,0]= np.arange(10)
df = pd.DataFrame(y, columns=["X", "A", "B", "C"])

df.head()

enter image description here

df.plot(x='X', y=['A', 'B', 'C'], kind='bar')

enter image description here

How can I plot df.plot(y='1.0', x=['A', 'B', 'C'], kind='bar') # I want to put cell as X or Y axis.

I have copied the example from StackOverflow itself.

3
  • Row plot can be said. I tried df.iloc[1].plot(y=['A','B','C']) . Instead of index I want to pick specific column cell. Commented Aug 2, 2018 at 5:56
  • What do you expect to see? Commented Aug 2, 2018 at 6:14
  • This is a small dataset I have a bigger one so I want to see the change of values as a continuous line graph with respect to columns like 'A', 'B','C' .... Commented Aug 2, 2018 at 6:17

1 Answer 1

2

in the code below, you can select row values and graph them by their types, you can do this for each row, and you can analyse each col/row you want with it.

#df.plot(x='X',y=['A','B','C'],kind = 'bar')
y1 = df.iloc[0,1:].values #for first column (horizontal values)
x1 = ['A','B','C']
plt.plot(x1,y1)

this one was for 0.th row,

Sign up to request clarification or add additional context in comments.

1 Comment

you can also add title, xlabel, ylabel to analyse better

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.