Question: Does this function work to make this graph? def plot _ scenario ( profits , moves ) : Plot a mixed -

Does this function work to make this graph?
def plot_scenario(profits, moves):
""" Plot a mixed-color bar chart as specified by management in PF: Data Translator Final Project.
"""
import matplotlib.pyplot as plt
#data given
currencies =['AUD','CHF', 'EUR', 'JPY','GBP']
losses =[-6053.75,-149.36,-101.92,-14.34,-9.80]
colors =['blue', 'orange', 'green', 'red', 'purple']
labels =[
'Loss of $6053.75mm due to -3 std dev move in AUD',
'Loss of $149.36mm due to -3 std dev move in CHF',
'Loss of $101.92mm due to -3 std dev move in EUR',
'Loss of $14.34mm due to 3 std dev move in JPY',
'Loss of $9.80mm due to 1 std dev move in GBP'
]
#plot
fig, ax = plt.subplots()
bars = ax.bar(currencies, losses, color = colors)
#add legend
#bbox_to_anchor positions legend outside plot
ax.legend(bars, labels, loc = 'lower center', bbox_to_anchor =(0.5,-0.15), ncol =1)
#add title and labels
ax.set_title('Worst overnight scenario: loss of $6.33 bln')
ax.set_ylabel('Profit USD')
ax.set_xlabel('Currency')
#show x-axis ticks
plt.tight_layout()
#show plot
plt.show()
 Does this function work to make this graph? def plot_scenario(profits, moves):

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!