简体   繁体   中英

how to plot graph for one pandas dataframe cell with respect to some columns

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

在此处输入图片说明

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

在此处输入图片说明

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.

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,

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