1

I built a graph according to the dictionary data.

import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import numpy as np

TNRACG_T_OLD= {'need1': 27, 'need2': 36}
plt.bar(range(len(TNRACG_T_OLD)), TNRACG_T_OLD.values(), align='center', color='b', label="TNRACG_T_OLD")
plt.xticks(range(len(TNRACG_T_OLD)), TNRACG_T_OLD.keys())
plt.legend(bbox_to_anchor=(1.45, 1), ncol=1)
plt.ylabel(u'Costs of meeting needs,')
plt.xlabel(u'Name of needs')

plt.show()

TNRCG_T_OLD= {'need1': 120, 'need2': 72}
plt.bar(range(len(TNRCG_T_OLD)), TNRCG_T_OLD.values(), align='center', color='b', label="TNRCG_T_OLD")
plt.xticks(range(len(TNRCG_T_OLD)), TNRCG_T_OLD.keys())
plt.legend(bbox_to_anchor=(1.45, 1), ncol=1)
plt.ylabel(u'Costs of meeting needs,')
plt.xlabel(u'Name of needs')

plt.show()

enter image description here The default graphics are placed to the right one column.

What to fix in the code of the program, so that the graphs are placed in two columns. As shown below.

enter image description here

Yaroslav
  • 87
  • 2
  • 10
  • Where can I find the answer to my question? I unfortunately did not find such a question. – Yaroslav Oct 23 '17 at 13:43
  • You need to create two subplots within a figure as shown in the duplicate. Alternatively, Google "matplotlib subplots" – DavidG Oct 23 '17 at 13:52
  • [This](https://stackoverflow.com/questions/31726643/how-do-i-get-multiple-subplots-in-matplotlib) perhaps gives another explanation. – DavidG Oct 23 '17 at 13:52
  • If a similar question was asked earlier. Should I delete this question? – Yaroslav Oct 23 '17 at 17:49
  • You can either leave it as a duplicate, or delete it, it's up to you. – DavidG Oct 24 '17 at 08:20

0 Answers0