Barchart with vertical labels in python/matplotlib

后端 未结 4 1104
栀梦
栀梦 2021-01-31 07:17

I\'m using matplotlib to generate a (vertical) barchart. The problem is my labels are rather long. Is there any way to display them vertically, either in the bar or above it or

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-31 07:31

    In Jupyter Notebook you might use something like this

    %matplotlib inline
    import matplotlib.pyplot as plt
    import numpy as np
    
    plt.xticks(rotation='vertical')
    plt.plot(np.random.randn(100).cumsum())
    

    or you can use:

    plt.xticks(rotation=90)
    

提交回复
热议问题