0

Matplotlib appears to not be plotting several points despite me changing the x-limit based on the inputted numbers I am trying to graph. (x-limit because this is a horizontal barplot).

Here is the code:

    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()

Here is the output: Output of the plot

6
  • @BigBen Unfortunately that didn't change anything within the output besides the tick mark format. I do like how it looks now, but still isn't correctly plotting the data Commented Jun 16, 2021 at 14:04
  • 2
    ax.set(xscale='symlog') Commented Jun 16, 2021 at 14:12
  • @TrentonMcKinney Thank you so much! Can you post this as an answer so I can upvote and accept? Also, do you have any good resources for python/matplotlib? Best! Commented Jun 16, 2021 at 14:16
  • Glad that helped. I'm just going to close it as a duplicate Commented Jun 16, 2021 at 15:47
  • @TrentonMcKinney is there a way to remove scientific notation on the x axis after I use your line of code from above? I googled around but couldn't find a solution tbh. Thanks again. Commented Jun 16, 2021 at 18:02

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.