%matplotlib inline
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(2,1,1)
ax.set_title("Summer Open Thread")
dlist = [((6,6),4093,2641), ((6,13),6036,3675),
((6,20),3103,1825), ((6,27),7572,5292),
((7,4),2105, 1254), ((7,11),3552, 2408)]
d,v, u = zip(*dlist)
ax.scatter(u,v, s=200)
ax.set_xlabel("Uniques", fontsize=14)
ax.set_ylabel("Views", fontsize=14)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
plt.xkcd()
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(2,1,1)
ax.set_title("Summer Open Thread")
dlist = [((6,6),4093,2641), ((6,13),6036,3675),
((6,20),3103,1825), ((6,27),7572,5292),
((7,4),2105, 1254), ((7,11),3552, 2408)]
d,v, u = zip(*dlist)
ax.scatter(u,v, s=200)
ax.set_xlabel("Uniques")
ax.set_ylabel("Views")
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
plt.xkcd()
fig = plt.figure(figsize=(12,12))
ax = fig.add_subplot(2,1,1)
ax.set_title("Summer Open Thread")
dlist = [((6,6),4093,2641), ((6,13),6036,3675),
((6,20),3103,1825), ((6,27),7572,5292),
((7,4),2105, 1254), ((7,11),3552, 2408)]
d,v, u = zip(*dlist)
ax.set_xlim(1000,8000)
ax.set_ylim(1000,8000)
ax.set_aspect('equal')
ax.scatter(u,v, s=200)
ax.set_xlabel("Uniques")
ax.set_ylabel("Views")
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
import matplotlib.pyplot as plt
from matplotlib.dates import MonthLocator, DateFormatter
import datetime as dt
plt.xkcd()
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(1,1,1)
ax.set_title("Summer Open Thread Readership")
dlist = [((6,6),74), ((6,13),38),
((6,20),109), ((6,27),79),
((7,4),54), ((7,11),87)]
d,v = zip(*dlist)
dates = [dt.date(2014, m, da) for m, da in d]
# every month
yearsFmt = DateFormatter('%m-%d')
#ax.xaxis.set_major_formatter(yearsFmt)
#ax.set_xlim((dates[0],dates[-1]))
#ax.xaxis.set_minor_locator(months)
ax.plot(range(len(d)), v, '-', color='k')
#ax.xaxis.set_ticks(d)
ax.xaxis.set_ticklabels(["{}/{}".format(m,da) for m,da in d])
ax.set_ylabel("Comments")
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
import matplotlib.pyplot as plt
from matplotlib.dates import MonthLocator, DateFormatter
import datetime as dt
plt.xkcd()
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(1,1,1)
ax.set_title("Summer Open Thread Readership")
dlist = [((6,6),74), ((6,13),38),
((6,20),109), ((6,27),79),
((7,4),54), ((7,11),87)]
d,v = zip(*dlist)
dates = [dt.date(2014, m, da) for m, da in d]
# every month
yearsFmt = DateFormatter('%m-%d')
#ax.xaxis.set_major_formatter(yearsFmt)
#ax.set_xlim((dates[0],dates[-1]))
#ax.xaxis.set_minor_locator(months)
ax.plot(range(len(d)), v, '-', color='k')
#ax.xaxis.set_ticks(d)
ax.xaxis.set_ticklabels(["{}/{}".format(m,da) for m,da in d])
ax.set_ylabel("Comments")
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.set_ylim((0,1000))
(0, 1000)
import matplotlib.pyplot as plt
from matplotlib.dates import MonthLocator, DateFormatter
import datetime as dt
plt.xkcd()
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(2,1,1)
ax.set_title("Summer Open Thread")
dlist = [((6,6),4093,2641), ((6,13),6036,3675),
((6,20),3103,1825), ((6,27),7572,5292),
((7,4),2105, 1254), ((7,11),3552, 2408)]
d,v, u = zip(*dlist)
ax.plot(range(len(d)), v, '-', color='k', label='views')
ax.plot(range(len(d)), u, color='r', label='uniques')
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.xaxis.set_ticklabels(["{}/{}".format(m,da) for m,da in d])
ax.legend(loc=4, borderaxespad=0.)
#ax.legend(ncol=2, bbox_to_anchor=(0, 1, 1., .102), loc=3, mode='expand')
<matplotlib.legend.Legend at 0x22f12c88>
import matplotlib.pyplot as plt
from matplotlib.dates import MonthLocator, DateFormatter
import datetime as dt
plt.xkcd()
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(2,1,1)
ax.set_title("Summer Open Thread")
dlist = [((6,6),4093,2641), ((6,13),6036,3675),
((6,20),3103,1825), ((6,27),7572,5292),
((7,4),2105, 1254), ((7,11),3552, 2408)]
d,v, u = zip(*dlist)
ax.plot(range(len(d)), v, '-', color='k', label='Total')
ax.plot(range(len(d)), u, color='r', label='Unique')
ax.set_ylabel("Pageviews")
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.xaxis.set_ticklabels(["{}/{}".format(m,da) for m,da in d])
ax.legend(borderaxespad=0.)
<matplotlib.legend.Legend at 0xa81dcf8>
import matplotlib.pyplot as plt
plt.xkcd()
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(2,1,1)
ax.set_title("Summer Open Thread")
dlist = [((6,6),4093,2641), ((6,13),6036,3675),
((6,20),3103,1825), ((6,27),7572,5292),
((7,4),2105, 1254), ((7,11),3552, 2408)]
d,v, u = zip(*dlist)
ax.plot(range(len(d)), v, '-', color='k', label='Total')
ax.plot(range(len(d)), u, color='r', label='Unique')
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.xaxis.set_ticklabels([])
ax.legend(loc=4, borderaxespad=0.)
<matplotlib.legend.Legend at 0xb38a160>
import matplotlib.pyplot as plt
from matplotlib.dates import MonthLocator, DateFormatter
import datetime as dt
plt.xkcd()
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(2,1,1)
ax.set_title("Summer Open Thread")
dlist = [((6,6),4093,2641), ((6,13),6036,3675),
((6,20),3103,1825), ((6,27),7572,5292),
((7,4),2105, 1254), ((7,11),3552, 2408)]
d,v, u = zip(*dlist)
ax.plot(range(len(d)), v, '-', color='k', label='views')
ax.plot(range(len(d)), u, color='r', label='uniques')
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.xaxis.set_ticklabels(["{}/{}".format(m,da) for m,da in d])
ax.legend()
#ax.legend(ncol=2, bbox_to_anchor=(0, 1, 1., .102), loc=3, mode='expand')
<matplotlib.legend.Legend at 0x22d88550>
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(1,1,1)
names, count = zip(*[('story645',5), ('BrokeinMileEnd', 4),
('umataro42',3), ('KyleGalloway',3 ),
('Others', 5)])
import numpy as np
width=.75
inds = np.arange(len(count))
ax.set_title("Hackerspace Front Page")
ax.bar(inds, count, width=width)
ax.xaxis.set_ticks(inds+width/2)
ax.xaxis.set_ticklabels(names, rotation=15)
ax.set_xlabel("Author")
ax.set_ylabel("Post or Share")
ax.get_yaxis().tick_left()
ax.set_xlim((0,len(count)-.25))
ax.xaxis.set_ticks_position('none')
ax.yaxis.set_ticks_position('none')
fig = plt.figure(figsize=(12,12))
ax = fig.add_subplot(1,1,1)
names, count = zip(*[('story645',5), ('BrokeinMileEnd', 4),
('umataro42',3), ('KyleGalloway',3 ),
('Others', 5)])
p = [c/(1.0*sum(count)) for c in count]
print p
import numpy as np
width=.75
inds = np.arange(len(count))
ax.set_title("Hackerspace Front Page")
ax.pie(p, labels=names, autopct='%d%%')
ax.set_aspect('equal')
[0.25, 0.2, 0.15, 0.15, 0.25]
fig = plt.figure(figsize=(12,12))
ax = fig.add_subplot(1,1,1)
names, count = zip(*[('story645',5), ('BrokeinMileEnd', 4),
('umataro42',3), ('KyleGalloway',3 ),
('Others', 5)])
p = [c/(1.0*sum(count)) for c in count]
width=.75
inds = np.arange(len(count))
ax.set_title("Which author has the most posts on the Hackerspace front page?")
ax.pie(p, labels=names, autopct='%d%%')
ax.set_aspect('equal')
fig = plt.figure(figsize=(12,9))
ax = fig.add_subplot(1,1,1)
names, count = zip(*[('story645',5), ('BrokeinMileEnd', 4),
('umataro42',3), ('KyleGalloway',3 ),
('Others', 5)])
width=.75
inds = np.arange(len(count))
ax.set_title("Hackerspace Front Page")
ax.plot(inds, count)
ax.xaxis.set_ticks(inds)
ax.xaxis.set_ticklabels(names, rotation = 15)
ax.set_xlabel("Author")
ax.set_ylabel("Post or Share")
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.set_ylim((0,5))
(0, 5)
import matplotlib.colors as mcolors
data = np.random.randn(50,50)
vmax = np.abs(data).max(())
norm = mcolors.Normalize(-vmax, vmax)
print data
fig = plt.figure(figsize=(12,6))
ax1 = fig.add_subplot(1,3,1)
im1 = ax1.imshow(data, cmap='Purples')
fig.colorbar(im1, ax=ax1, fraction=0.045)
ax1.set_xticks([])
ax1.set_yticks([])
ax1.set_title("Sequential")
ax2 = fig.add_subplot(1,3,2)
im2 = ax2.imshow(data, cmap='RdBu')
fig.colorbar(im2, ax=ax2, fraction=0.045)
ax2.set_xticks([])
ax2.set_yticks([])
ax2.set_title("Diverging")
ax3 = fig.add_subplot(1,3,3)
ax3.set_xticks([])
ax3.set_yticks([])
im3 = ax3.imshow(data, cmap='Accent')
ax3.set_title("Qualitative")
fig.colorbar(im3, ax=ax3, fraction=0.045)
[[-0.01318061 0.05711868 -1.027301 ..., -0.30654195 -0.98430202 0.48912191] [-0.05111255 -0.8914386 -0.15800618 ..., 1.57923874 0.25596595 -1.83797306] [ 0.89693064 0.1328054 -0.93910538 ..., -0.17210677 -0.68065345 0.36864782] ..., [-0.01814914 -1.27217575 -1.73144709 ..., -1.13507501 -0.52215138 1.2768046 ] [ 0.15764372 0.13729613 0.50872309 ..., -0.79863125 0.02895824 -0.49220971] [-0.24876455 0.23893093 -0.43007072 ..., -1.41331405 0.63192807 0.59453711]]
<matplotlib.colorbar.Colorbar instance at 0x00000000221B8388>