I am new to matplotlib. I would like to create a simple bar chart, providing absolute frequencies. Data and code are below. What I would have liked to write is:
elecData[elecData["year"]==1982].plot(x="party", y="votes", kind="bar")
The y-axis does not plot the absolute vote values, however, but shows me some kind of transformed scale with a max. value of 1. In an attempt to solve this issue, I have tried to reproduce other examples which usually generate plots either from a single pd.Series or a DF which only includes the relevant variables. Hence I converted the variable "party" to an index and then reduced the DF to "votes" with [[]]. This still did not solve the problem. Please could you show me how to do what I want to do. Thank you!
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
a = {'year': {0: 1982, 1: 1986, 2: 1989, 3: 1993, 4: 1977, 5: 1979, 6: 1982, 7: 1986, 8: 1989, 9: 1993, 10: 1996, 11: 1977, 12: 1979, 13: 1982, 14: 1986, 15: 1989, 16: 1993, 17: 1996, 18: 1977, 19: 1979, 20: 1982, 21: 1986, 22: 1989, 23: 1993, 24: 1996, 25: 1977, 26: 1979, 27: 1982, 28: 1986, 29: 1989, 30: 1993, 31: 1996, 32: 1977, 33: 1979, 34: 1982, 35: 1986, 36: 1989, 37: 1993, 38: 1996, 39: 1977, 40: 1979, 41: 1982, 42: 1986, 43: 1989, 44: 1993, 45: 1996, 46: 1977, 47: 1979, 48: 1982}, 'month': {0: 10, 1: 6, 2: 10, 3: 6, 4: 6, 5: 3, 6: 10, 7: 6, 8: 10, 9: 6, 10: 3, 11: 6, 12: 3, 13: 10, 14: 6, 15: 10, 16: 6, 17: 3, 18: 6, 19: 3, 20: 10, 21: 6, 22: 10, 23: 6, 24: 3, 25: 6, 26: 3, 27: 10, 28: 6, 29: 10, 30: 6, 31: 3, 32: 6, 33: 3, 34: 10, 35: 6, 36: 10, 37: 6, 38: 3, 39: 6, 40: 3, 41: 10, 42: 6, 43: 10, 44: 6, 45: 3, 46: 6, 47: 3, 48: 10}, 'party': {0: 'CDS', 1: 'CDS', 2: 'CDS', 3: 'CDS', 4: 'CIU', 5: 'CIU', 6: 'CIU', 7: 'CIU', 8: 'CIU', 9: 'CIU', 10: 'CIU', 11: 'ERC', 12: 'ERC', 13: 'ERC', 14: 'ERC', 15: 'ERC', 16: 'ERC', 17: 'ERC', 18: 'IU', 19: 'IU', 20: 'IU', 21: 'IU', 22: 'IU', 23: 'IU', 24: 'IU', 25: 'PNV', 26: 'PNV', 27: 'PNV', 28: 'PNV', 29: 'PNV', 30: 'PNV', 31: 'PNV', 32: 'PP', 33: 'PP', 34: 'PP', 35: 'PP', 36: 'PP', 37: 'PP', 38: 'PP', 39: 'PSOE', 40: 'PSOE', 41: 'PSOE', 42: 'PSOE', 43: 'PSOE', 44: 'PSOE', 45: 'PSOE', 46: 'UCD', 47: 'UCD', 48: 'UCD'}, 'votes': {0: 604309, 1: 1861912, 2: 1617716, 3: 414740, 4: 514647, 5: 483353, 6: 772726, 7: 1014258, 8: 1032243, 9: 1165783, 10: 1151633, 11: 143954, 12: 123452, 13: 138118, 14: 84628, 15: 84756, 16: 189632, 17: 167641, 18: 1709890, 19: 1938487, 20: 846515, 21: 935504, 22: 1858588, 23: 2253722, 24: 2639774, 25: 296193, 26: 296597, 27: 395656, 28: 309610, 29: 254681, 30: 291448, 31: 318951, 32: 1504771, 33: 1060330, 34: 5548107, 35: 5247677, 36: 5285972, 37: 8201463, 38: 9716006, 39: 5371866, 40: 5469813, 41: 10127392, 42: 8901718, 43: 8115568, 44: 9150083, 45: 9425678, 46: 6310391, 47: 6268593, 48: 1425093}, 'seats': {0: 2, 1: 19, 2: 14, 3: 0, 4: 11, 5: 8, 6: 12, 7: 18, 8: 18, 9: 17, 10: 16, 11: 1, 12: 1, 13: 1, 14: 0, 15: 0, 16: 1, 17: 1, 18: 20, 19: 23, 20: 4, 21: 7, 22: 17, 23: 18, 24: 21, 25: 8, 26: 7, 27: 8, 28: 6, 29: 5, 30: 5, 31: 5, 32: 16, 33: 9, 34: 107, 35: 105, 36: 107, 37: 141, 38: 156, 39: 118, 40: 121, 41: 202, 42: 184, 43: 175, 44: 159, 45: 141, 46: 165, 47: 168, 48: 11}}
elecData = pd.DataFrame.from_dict(a)
elecData[elecData["year"]==1982].set_index("party")[["votes"]].plot(kind="bar")