0

Here is the code:

plt.figure(figsize=(15,6)) # does not affect the following plot
fig, ax = plt.subplots()
ax.set_xticklabels(q9.columns.values[::-1], fontproperties=label_font, fontsize=14)
sns.barplot(q9.columns.values, q9.iloc[[1]].get_values()[0], palette="GnBu_d", ax=ax)

I had to set the font in this case, so I need the ax object. The final plot is really small, definitely not (15,6). I think by setting ax=ax changed the size of the plot to its default size.

Any idea on how to change the size of the figure in this case?

2
  • 1
    Remove the first line. In the second line, add the figsize argument fig, ax = plt.subplots(figsize=(15,6)) Commented Nov 6, 2016 at 12:56
  • @ImportanceOfBeingErnest Thank you! Commented Nov 6, 2016 at 14:21

1 Answer 1

1

You are making two figures, with the call to plt.figure and plt.subplots. You are setting the size only on the first figure, but you are using the second figure to draw your barplot.

Sign up to request clarification or add additional context in comments.

2 Comments

Since I am new to seaborn and matplotlib, could you show me the code to change the size of the plot. I think there are two solutions: 1. I shouldn't get the ax from the second figure, but I don't know how to create one 2. how to change the size of the seaborn barplot.
plt.subplots has a figsize parameter, which you will see if you look at its docstring.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.