-
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
Conversation
in response to this issue |
self.canvas.draw() | ||
if self.is_normalized: | ||
print("normy") | ||
for i in range(0, len(self.key_list)): |
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 can just write range(len(...))
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.
or even better
for i, k in enumerate(self.key_list):
temp_x = blob[k][0].copy()
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.
for even more compactness:
blob = your_data # normalized or not
sub_blob = [blob[k] for k in self.key_list]
for i, (x, y) in enumerate(sub_blob):
self.ax.plot(x + i * offsetx, y + i * offsety)
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.
Actually, you might not need the sub_blob
. Do you allow the number of data sets to not equal the number of keys? If not then just skip the sub_blob line.
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.
No, you can only get the data if there is a key for it. There should never be a time there is not a key for the data.
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.
Great than you can just do a two liner
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.
Also, you don't need 0 in the range call.
How does the waterfall plot handle different color maps? Can you change the waterfall's colors? |
@CJ-Wright do you mean for the 3d or the 2d waterfall maps? |
Both? I guess I meant, are the color maps changeable? |
self.canvas.draw() | ||
else: | ||
print("4chan") | ||
for i in range(0, len(self.key_list)): |
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.
This can just be range(len(self.key_list))
In brief I would go with: self.ax.cla()
title = 'Data not normalized'
if self.is_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.title(title)
self.ax.autoscale()
self.canvas.draw() Also one might go with ordered dicts for the data if you just want to pull it out sequentially |
I don't know how long/expensive this code is or where the most expensive part is, but you can parallelize the for loop with a map. |
its not too expensive, but i can parallelize it for really large datasets |
@CJ-Wright to answer the question about the colormaps being changeable, we have not added that in as a feature yet for the three-d waterfall plots, because we just haven't yet. For the 2d plots matplotlib whenever you add a new plot to the graph simply changes the color of the line to show that it is a different plot automatically. In that sense for 2d waterfall you don't choose the color, you just choose the fact that all the lines will be different colors. |
Would it be possible to set the colormap similar to how I had it set in my graphing scripts? Basically you know the number of lines then use that as the max for the color map. Then use the colormap to set the line color based on the index of the line. |
@CJ-Wright Yeah, that was the way I was thinking of doing it. |
also, im having issues with python not recognizing class attributes when running xpdView. I get an error saying that normalized is not an attribute of the Waterfall2D class when it clearly is. When initializing a waterfall 2d object in an ipython session, the normalized attribute is there. Do any of you have an idea why that would be? |
@JKThanassi Do you have some |
@CJ-Wright the |
I use it so often I have a .bashrc alias for it: psd |
As of right now the button is in place but the graph is not updating. Will finish fixing it tomorrow.