I have a simple grouped barplot, as in the example given below. I don't like the fact that the end result turns out quite large, and would like to change the height - but without changing the width. This is presumably quite simple, but I cannot figure it out.
How can I achieve this, and similarly, how could I change the width?
EDIT: So thanks to this question (it is also in the duplicate question, slightly hidden) I finally found out that I have been placing the figure resizing command
plt.figure(figsize=(10,15))
at the wrong place in the code all the time. If I place it directly after
sns.set(style='white')
the figure size actually does change.
However, now I get two popup windows: one named Figure 1 (the one that I want), and a second small line graph named Figure 2. Additionally, I get a warning:
QWindowsWindow::setGeometry: Unable to set geometry 1000x1566+8+31 on QWidgetWindow/'MainWindowClassWindow'.
Resulting geometry: 1000x749+8+31 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 67x66, maximum size: 16777215x16777215).
QWindowsWindow::setGeometry: Unable to set geometry 100x166+633+281 on QWidgetWindow/'MainWindowClassWindow'.
Resulting geometry: 124x166+633+281 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 67x66, maximum size: 16777215x16777215).
Interestingly, I only get the second popup and the warning in the simplified example below, and not when making the actual graph that this is a simplification of. I would be curious to know why this is.
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
title = 'Title'
parts = ['A', 'B', 'C', 'D']
items = ['one','two','three','four','five']
sns.set(style='white')
plt.title(title,fontsize=18)
ax = plt.gca()
ax.grid(which='major', axis='y', linestyle=':')
plt.xlabel('Item', fontsize=16)
pos = np.arange(len(items))
plt.xticks(pos, items)
plt.ylabel('Count', fontsize=16)
y_ticks = [0, 20, 40, 60, 80]
ax.set_yticks(y_ticks, minor=False)
full_bar_width = 0.2
bar_width = 0.15
all_A = [72, 74, 74, 70, 72]
all_B = [67, 69, 67, 65, 67]
all_C = [67, 67, 64, 63, 65]
all_D = [57, 64, 57, 55, 58]
plt.bar(pos-(1.5*full_bar_width),all_A,bar_width,color='red')
plt.bar(pos-(0.5*full_bar_width),all_B,bar_width,color='blue')
plt.bar(pos+(0.5*full_bar_width),all_C,bar_width,color='cyan')
plt.bar(pos+(1.5*full_bar_width),all_D,bar_width,color='green')
plt.legend(parts,bbox_to_anchor=(1.04,0.5), loc='center left')
plt.subplots_adjust(right=0.8)
plt.show()