I am am trying to plot a bar graph in the following manner:
# importing package
import matplotlib.pyplot as plt
import pandas as pd
# create data
df = pd.DataFrame([['A', 10, 20, 10, 30], ['B', 20, 25, 15, 25], ['C', 12, 15, 19, 6],
['D', 10, 29, 13, 19]],
columns=['Team', 'Round 1', 'Round 2', 'Round 3', 'Round 4'])
# view data
print(df)
# plot grouped bar chart
df.plot(x='Team',
kind='bar',
stacked=False,
title='Grouped Bar Graph with dataframe')
However, the size of the bar graph is very small. What changes should I make in order to make the bar graph bigger both in length and breadth?
You can use the width parameter
df.plot(x='Team',
kind='bar',
stacked=False,
title='Grouped Bar Graph with dataframe',
width=0.5)
df.plot(x='Team',
kind='bar',
stacked=False,
title='Grouped Bar Graph with dataframe',
figsize = (10,10))
Result: ( Uncomfortably big bar plot)
For changing the colormap use the colormap
parameter.
from matplotlib import cm
...
df.plot(x='Team',
kind='bar',
stacked=False,
title='Grouped Bar Graph with dataframe',
figsize = (5,5),
colormap = cm.get_cmap('Spectral') )
See the documentation for pandas.plot. The parameter you are looking for is figsize. Pandas Plot Documentation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.