Question
import matplotlib.pyplot as plt def autolabel(rectangle_group): for rect in rectangle_group: height = rect.get_height() ax.annotate(str(height), xy = (rect.get_x() + rect.get_width() / 2,height), ha = 'center', xytext
import matplotlib.pyplot as plt
def autolabel(rectangle_group): for rect in rectangle_group: height = rect.get_height()
ax.annotate(str(height), xy = (rect.get_x() + rect.get_width() / 2,height), ha = 'center', xytext = (0,3),textcoords = 'offset points', color = 'grey')
phases = ['Mid 90s','Early 2k','Mid 2k','Mid 2010s'] playstation = [102 , 155 , 87 , 110 ] pc_sales = [71 , 128 , 240 , 316 ]
width = 0.2 x_playstation = [x - width for x in range(len(playstation))] x_xbox = [x for x in range(len(xbox))] x_nintendo = [x + width for x in range(len(nintendo))]
fig,ax = plt.subplots()
rect1 = ax.bar(x_playstation, playstation,width, label = 'Playstation',color = 'darkslategray') ax.plot(phases,pc_sales,label = 'PC Sales',color = 'black',marker = 'o')
ax.set_title('The hardware market') ax.set_ylabel('Total sales (in millions)') ax.legend()
autolabel(rect1)
plt.show()
How to create another y-xis on the right side? and how to change the colour to align each of the y-axes with each of bar and line graph (for example, if bar bar chart is blue, y-xis on the left side also coloured blue)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started