Matplotlib 没有在水平条形图上绘制多个点?

时间:2021-06-16 13:57:20

标签: python python-3.x matplotlib graphing

尽管我根据要绘制的输入数字更改了 x 限制,但 Matplotlib 似乎没有绘制多个点。 (x-limit 因为这是一个水平条形图)。

代码如下:

    low = min(df_grouped_underlying['Currency Exposure'].astype(float))
    high = max(df_grouped_underlying['Currency Exposure'].astype(float))
    fig = plt.figure()
    ax = fig.add_subplot()
    ax.set_xlim([math.ceil(low-0.5*(high-low)), math.ceil(high+0.5*(high-low))])
    bar_1 = ax.barh(df_grouped_underlying.index, df_grouped_underlying['Currency Exposure'].astype(float), label='Currency Exposure')
    ax.set(title = 'Currency_Exposure_Underlying_Position',
       ylabel = 'Underlying Currency',
       xlabel = 'Exposure')
    plt.legend(loc="upper right")
    plt.savefig('agg_exposure.png', bbox_inches='tight') 
    plt.show()

这是输出: Output of the plot

0 个答案:

没有答案
相关问题