简体   繁体   English

如何为python的“iplot”中的给定点更改相应的X轴标签

[英]How can i change the corresponding X-Axis Label for a given point in 'iplot' of python

This is the image which i have generated using iplot in python这是我在 python 中使用 iplot 生成的图像

How can i show the corresponding data element name , when i am using iplot function .当我使用 iplot 函数时,如何显示相应的数据元素名称。 I have used the following commmand to create the plot我使用以下命令来创建情节

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

Here val,val2,val3 are the Pandas.Series and the corresponding columns are 'Third' , 'Fourth' , 'Sixth' , and for these columns corresponding to the roll number of each student, i want to plot the graph using iplot , showing roll number instead of series of [1,2,3,.. ] in x -axis The corresponding roll numbers are present as series as roll_series.这里 val,val2,val3 是 Pandas.Series 和相应的列是 'Third' , 'Fourth' , 'Sixth' ,对于与每个学生的卷号相对应的这些列,我想使用 iplot 绘制图形,在 x 轴上显示卷号而不是 [1,2,3,..] 的系列 相应的卷号以 roll_series 的系列形式存在。

Thank you in advance for help预先感谢您的帮助

One way would be to put all the series in a dataframe and plot as below.一种方法是将所有系列放在一个数据框中并绘制如下。

# 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()使用 iplot() 在 x 轴上绘制学生卷号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM