-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option for normalizing data in waterfall plot #31
Changes from all commits
31e3ca3
ea2d9d8
f0e87dd
c567762
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ def __init__(self, key_list, data_dict, fig, canvas): | |
self.data_dict = data_dict | ||
self.key_list = key_list | ||
self.fig = fig | ||
self.normalized = False | ||
self.canvas = canvas | ||
self.ax = self.fig.add_subplot(111) | ||
self.x_offset = 0 | ||
|
@@ -50,16 +51,25 @@ def generate_waterfall(self): | |
None | ||
""" | ||
self.ax.cla() | ||
# self.ax.hold(True) | ||
for i in range(0, len(self.key_list)): | ||
temp_x = self.normalized_data[self.key_list[i]][0].copy() | ||
temp_y = self.normalized_data[self.key_list[i]][1].copy() | ||
temp_x += self.x_offset * i | ||
temp_y += self.y_offset * i | ||
self.ax.plot(temp_x, temp_y) | ||
title = 'Data not normalized' | ||
if self.normalized: | ||
data = self.normalized_data | ||
title = 'Data Normalized' | ||
else: | ||
data = self.data_dict | ||
list_data = (data[k] for k in self.key_list) # you can do a list comp here too | ||
for i, (x, y) in enumerate(list_data): | ||
self.ax.plot(x + self.x_offset * i, y + self.y_offset * i) | ||
self.ax.set_title(title) | ||
self.ax.autoscale() | ||
self.canvas.draw() | ||
|
||
def is_normalized(self): | ||
return self.normalized | ||
|
||
def set_normalized(self, state): | ||
self.normalized = state | ||
|
||
def normalize_data(self): | ||
"""This method normalizes data for plotting | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also note that you could do this with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also you might look into using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean the |
||
|
||
|
@@ -72,4 +82,4 @@ def normalize_data(self): | |
temp = self.data_dict[key].copy() | ||
temp[1] = temp[1] - temp[1].min() | ||
temp[1] = temp[1] / (temp[1].max() - temp[1].min()) | ||
self.normalized_data[key] = temp | ||
self.normalized_data[key] = temp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might compress this into two chunks, the part which does the normalizeation (or not) and the part which does the
ax.autoscale()
andcanvas.draw()
since those are sharedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could compress this even more, since the
temp_x = blob
logic is the same. Maybe something like this: