Search code examples
pythonpandasgraphchartsline

Insert a 2 horizontal lines on a bar plot


I am trying to insert 2 lines on a bar plot with the following code:

PosisEink_Liq['weights'].plot(kind='bar',color=('darkgray'))
PosisEink_Liq['TAA+1'].plot(kind='line',color=('black'),linestyle = '--')
PosisEink_Liq['TAA-1'].plot(kind='line',color=('black'),linestyle = '--')

Unfortunately, the 2 horizontal lines do not happear along the all graph from right to left. Do you know a remedy for this problem. If possible no plot.axhline formula


Solution

  • Use

    import pandas as pd
    import matplotlib.pyplot as plt
    plt.rcParams["figure.figsize"] = [7.50, 3.50] #Size of Graph
    plt.rcParams["figure.autolayout"] = True
    fig, ax = plt.subplots() #For multiple subplots