gpt4 book ai didi

python - 如何更改 python 'iplot' 中给定点的相应 X 轴标签

转载 作者:太空宇宙 更新时间:2023-11-03 14:06:43 25 4
gpt4 key购买 nike

This is the image which i have generated using iplot in python

当我使用 iplot 函数时,如何显示相应的数据元素名称。我使用以下命令来创建绘图

data_f = pd.DataFrame({'Third':val , 'Fourth':val2 , 'Sixth':val3  }  )
data_f.iplot( )

这里 val,val2,val3 是 Pandas.Series ,相应的列是 'Third' , 'Fourth' , 'Sixth' ,对于与每个学生的卷数相对应的这些列,我想绘制图表使用 iplot ,在 x 轴上显示卷号而不是 [1,2,3,.. ] 系列相应的卷号以系列形式显示为 roll_series。

提前感谢您的帮助

最佳答案

一种方法是将所有系列放入数据框中并绘制如下图。

# Create series val, val1, val3 and roll_num
val = np.random.randn(10)
val2 = np.random.randn(10)
val3= np.random.randn(10)
roll_num = np.linspace(start=1001,stop=1010,num=10)

# Create dataframe from above series
df = pd.DataFrame({'val': val, 'val2': val2, 'val3': val3, 'roll_num':roll_num})
df.head(2)

# Plot using iplot() where x-axis now shows student roll number
df.iplot(x='roll_num', y=['val', 'val2', 'val3'], xTitle='Student Roll Number',yTitle='Score',title='Class Scores')

Plot with student roll number on x-axis using iplot()

关于python - 如何更改 python 'iplot' 中给定点的相应 X 轴标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48838287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com