# Author: Ika, 9/1/2013
# Code to generate the last frame.
from matplotlib.pyplot import *
from numpy import linspace, arange
from matplotlib.patches import Polygon
x1 = linspace(0,9,100)
y1 = 3100/(x1**1.4)
x2 = linspace(1,8,8)
y2 = 3100/(x2**1.4)
x3 = arange(1,6,0.01)
y3 = 3100/(x3**1.4)
verts = [(1,0)] + zip(x3,y3) + [(6,0)]
poly = Polygon(verts, facecolor='yellow',edgecolor='k')
fig = figure(figsize=(5,5))
ax = fig.add_subplot(111)
ax.grid(False)
ax.plot(x1,y1)
#ax.plot(x2,y2,'ro')
ax.add_patch(poly)
ax.text(4,2500,r"$PV^K=3100$",size=20)
ax.text(1.1,3100,"1",size=36)
ax.text(6,230,"2",size=36)
ax.text(1.0,250,r"$W=\int_1^2P\mathrm{d}V$",size=16)
ax.set_ylim(0,3720)
ax.set_yticks(linspace(0,3100,6))
ax.minorticks_on()
ax.set_xlabel("V")
ax.set_ylabel("P")
fig.savefig("adiabatic_5.png",bbox_inches="tight",\
pad_inches=.15)