Commit 74c38e96 by devttys0

Finished replacing matplotlib with pyqtgraph.

parent 9aed6246
...@@ -14,10 +14,14 @@ class PlotEntropy(object): ...@@ -14,10 +14,14 @@ class PlotEntropy(object):
XLABEL = 'Offset' XLABEL = 'Offset'
YLABEL = 'Entropy' YLABEL = 'Entropy'
COLORS = ['r', 'g', 'b', 'c', 'm', 'w'] XUNITS = 'B'
YUNITS = 'E'
COLORS = ['r', 'g', 'c', 'b', 'm']
FILE_WIDTH = 1024
FILE_FORMAT = 'png'
FILE_FORMAT = 'svg'
def __init__(self, x, y, title='Entropy', average=0, file_results={}, show_legend=True, save=False): def __init__(self, x, y, title='Entropy', average=0, file_results={}, show_legend=True, save=False):
''' '''
Plots entropy data. Plots entropy data.
...@@ -53,11 +57,16 @@ class PlotEntropy(object): ...@@ -53,11 +57,16 @@ class PlotEntropy(object):
descriptions[offset] = [description] descriptions[offset] = [description]
#pg.setConfigOption('background', 'w')
#pg.setConfigOption('foreground', 'k')
plt = pg.plot(title=title, clear=True) plt = pg.plot(title=title, clear=True)
plt.plot(x, y, pen='y')
plt.plot(x, y, pen='y') #pen='b'
if file_results and show_legend: if file_results and show_legend:
plt.addLegend(size=(max_description_length*10, 0)) plt.addLegend(size=(max_description_length*10, 0))
# Don't really like the way pyqtgraph draws these infinite horizontal lines
#if average: #if average:
# plt.addLine(y=average, pen='r') # plt.addLine(y=average, pen='r')
...@@ -70,11 +79,13 @@ class PlotEntropy(object): ...@@ -70,11 +79,13 @@ class PlotEntropy(object):
i = 0 i = 0
if save: if save:
# TODO exporter = pg.exporters.ImageExporter.ImageExporter(plt.plotItem)
pass exporter.parameters()['width'] = self.FILE_WIDTH
#plt.savefig(common.unique_file_name(title, self.FILE_FORMAT)) exporter.export(common.unique_file_name(title, self.FILE_FORMAT))
else: else:
plt.setWindowTitle(title) # Only set the axis labels if we're displaying a live window (axis labels aren't well-placed when saving directly to file)
plt.setLabel('left', self.YLABEL, units=self.YUNITS)
plt.setLabel('bottom', self.XLABEL, units=self.XUNITS)
QtGui.QApplication.instance().exec_() QtGui.QApplication.instance().exec_()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment