Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Astrolitterbox
committed
Apr 20, 2012
1 parent
9e5fd9e
commit a9265d1
Showing
1 changed file
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Tue Feb 21 19:18:52 2012 | ||
@author: astrolitterbox | ||
""" | ||
import numpy as np | ||
#import db | ||
import matplotlib.pyplot as plt | ||
import matplotlib.font_manager | ||
|
||
|
||
class PlotTitles: | ||
def __init__(self, title, xlabel, ylabel): | ||
self.title = title | ||
self.xlabel = xlabel | ||
self.ylabel = ylabel | ||
|
||
|
||
class GraphData: | ||
def __init__(self, data, colour, legend): | ||
self.data = data | ||
self.colour = colour | ||
self.legend = legend | ||
|
||
class Plots: | ||
imgDir = './img/' | ||
def plotLogHist(self, graphDataList, filename, plotTitles, bins, *args): | ||
bins=10**np.arange(*bins) | ||
s = plt.figure() | ||
ax = s.add_subplot(111) | ||
try: | ||
args[0] | ||
except IndexError: | ||
print 'blah' | ||
else: | ||
v = list(args[0]) | ||
ax.axis(v) | ||
prop = matplotlib.font_manager.FontProperties(size=8) | ||
for gd in graphDataList: | ||
p1 = plt.hist((gd.data), color=gd.colour, bins = bins, histtype='barstacked', alpha=0.6) | ||
print gd.legend | ||
#plt.legend([p1], list(gd.legend), loc=0, markerscale=10, fancybox=True, labelspacing = 0.2, prop=prop, shadow=True) | ||
plt.title(plotTitles.title) | ||
plt.xlabel = plotTitles.xlabel | ||
plt.xscale('log') | ||
plt.ylabel = plotTitles.ylabel | ||
plt.savefig(self.imgDir+filename) | ||
|
||
def plotHist(self, graphDataList, filename, plotTitles, bins, barstacked=False, *args): | ||
s = plt.figure() | ||
ax = s.add_subplot(111) | ||
try: | ||
args[0] | ||
except IndexError: | ||
print 'blah' | ||
else: | ||
v = list(args[0]) | ||
ax.axis(v) | ||
# if barstacked == True: | ||
# p1 = plt.hist((gd.data), color=gd.colour, bins = bins, histtype='barstacked', normed=True, alpha=0.6) | ||
prop = matplotlib.font_manager.FontProperties(size=8) | ||
for gd in graphDataList: | ||
p1 = plt.hist((gd.data), color=gd.colour, bins = bins, normed=True, alpha=0.6) | ||
print gd.legend | ||
#plt.legend([p1], list(gd.legend), loc=0, markerscale=10, fancybox=True, labelspacing = 0.2, prop=prop, shadow=True) | ||
plt.title(plotTitles.title) | ||
plt.xlabel = plotTitles.xlabel | ||
plt.ylabel = plotTitles.ylabel | ||
plt.savefig(self.imgDir+filename) | ||
|
||
def plotScatter(self, graphDataList, filename, plotTitles, *args): | ||
s = plt.figure() | ||
ax = s.add_subplot(111) | ||
try: | ||
args[0] | ||
except IndexError: | ||
print 'blah' | ||
else: | ||
v = list(args[0]) | ||
ax.axis(v) | ||
prop = matplotlib.font_manager.FontProperties(size=8) | ||
for gd in graphDataList: | ||
p1 = ax.plot(gd.data[0], gd.data[1], ',', markersize=1, color=gd.colour, mec=gd.colour, alpha = 0.9) | ||
plt.legend([p1[0]], gd.legend, loc=0, markerscale=10, fancybox=True, labelspacing = 0.2, prop=prop, shadow=True) | ||
plt.title(plotTitles.title) | ||
plt.xlabel = plotTitles.xlabel | ||
plt.ylabel = plotTitles.ylabel | ||
plt.savefig(self.imgDir+filename) |