In [4]:
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import host_subplot
import mpl_toolkits.axisartist as AA
import numpy as np
%matplotlib inline
In [27]:
ax = host_subplot(111, axes_class=AA.Axes)
xx = np.arange(0, 2*np.pi, 0.01)
ax.plot(xx, np.sin(xx))
ax2 = ax.twin() # ax2 is responsible for "top" axis and "right" axis
ax2.set_xticks([0., .5*np.pi, np.pi, 1.5*np.pi, 2*np.pi])
ax2.set_xticklabels(["$0$", r"$\frac{1}{2}\pi$", r"$\pi$", r"$\frac{3}{2}\pi$", r"$2\pi$"])
ax2.axis["right"].major_ticklabels.set_visible(False)
plt.draw()
plt.show()
Dorian Auto manufactures luxury cars and trucs. The company believes that its most likely customers are high income women and men. To reach these groups, Dorian Auto has started an ambitious TV advertising and will purchase 1- minute commercial spots on 2 typeof programs: comedy shows and football shows.
Each comedy commercial is seen by 7 million high income women and 2million high income men and costs 50,000\$ per 1 minute commercial. Each football game is seen by 2 million high income women and 12 million high income men and 1 minute commercial costs 100 000\$ Dorian Auto likes the commercials to be seen by at least 28 million high income womwn and at least 24 million high income men.
x1 = number of 1-minute comedy ads purchased
x2 = number of 1-minute football ads purchased
Total advertising cost = cost of comedy ads + cost of football ads = 50x1 + 100x2
min z = 50x1 + 100x2
Constraint 1 Commercials must reach at least 28 million high-income women.
Constraint 2 Commercials must reach at least 24 million high-income men
7x1 + 2x2 >= 28
2x1 + 12x2 >= 24
In [52]:
import matplotlib.pyplot as plt
plt.plot([4,0],[0,14])
plt.plot([12,0],[0,2])
plt.plot([2,0],[0,1])
plt.plot([4,0],[0,2])
plt.plot([6,0],[0,3])
plt.plot([8,0],[0,4])
plt.plot([6.4,0],[0,3.2])
plt.plot([3.6],[1.4], "ro", color = "black")
plt.show()