x-axis inverted unexpectedly by pandas.plot(…)

前端 未结 3 1221
隐瞒了意图╮
隐瞒了意图╮ 2020-12-21 20:40

X axis was inverted automatically and unexpectedly when plotting a series of data against another series of data using pandas. Please look at my code below. How can I ensure

3条回答
  •  囚心锁ツ
    2020-12-21 21:34

    To invert the graph you can use

    arr1 = [1,2,3,4,5]
    arr2 = [9,8,4,3,8]
    df = pd.Dataframe(arr1,arr2)
    df.plot.barh()
    

    if you also want to print the graph in sorting then you can use

    df.sort_values().plot.barh()
    

    To enlarge the size of graph you can use

    df.sort_values().plot.barh(figsize=(10,20))
    
    

提交回复
热议问题