bar_chart
This function creates a bar chart.
bar_chart(**kwargs)
Input Variables
Name | Description | Type |
---|---|---|
plot_setup | Dictionary to configure the chart with the following keys:
| Dictionary |
dataset | Data to be plotted | List or array |
Output Variables
Name | Description | Type |
---|---|---|
None | The function displays the plot on the screen and saves it in the same folder as the | None |
Example 1
Use the bar_chart
function to perform a task.
# Data
df = pd.DataFrame({'x': ['2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022'],
'action': [15.00, 16.00, 17.00, 18.00, 19.00, 20.00, 21.00, 22.00, 23.00, 24.00],
'comedy': [12.00, 13.00, 14.00, 15.00, 16.00, 17.00, 18.00, 19.00, 20.00, 21.00],
'drama': [9.00, 10.00, 11.00, 12.00, 13.00, 14.00, 15.00, 16.00, 17.00, 18.00],
'horror': [8.00, 9.00, 10.00, 11.00, 12.00, 13.00, 14.00, 15.00, 16.00, 17.00],
'romance': [10.00, 11.00, 12.00, 13.00, 14.00, 15.00, 16.00, 17.00, 18.00, 19.00]
})
# Chart setup
chart_config = {
'name': 'figure1-4-1',
'width': 20,
'height': 12,
'bar width': .10,
'opacity': 0.7,
'y axis label': 'Revenue (USD billion)',
'y axis size': 14,
'x axis label': 'Year',
'x axis size': 14,
'axes color': 'green',
'labels size': 14,
'labels color': 'blue',
'colors': ['#E53935', '#FFB300', '#1E88E5', '#4CAF50', '#9C27B0'],
'on grid?': True,
'y log': False,
'dots per inch': 600,
'extension': 'svg',
}
# Data statement
data = {'dataset': df}
# Call function
bar_chart(dataset=data, plot_setup=chart_config)
Figure 1. Film Revenue by Category and Year.