Skip to content

Add plotting option to Fingerprint plot #787

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

Merged
merged 11 commits into from
Dec 8, 2016

Conversation

theref
Copy link
Member

@theref theref commented Dec 6, 2016

Adds:

  • option to have a color bar
  • option to have the axis labels

Copy link
Member

@drvinceknight drvinceknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good @theref, could you throw some of the images here to take a look?

Also, as the defaults are True (which I like) could you update the images for the docs?

@@ -267,7 +267,7 @@ def fingerprint(self, turns=50, repetitions=10, step=0.01, processes=None,
self.data = self.generate_data(self.interactions, self.points, edges)
return self.data

def plot(self, col_map='seismic', interpolation='none', title=None):
def plot(self, col_map='seismic', interpolation='none', title=None, colorbar=True, labels=True):
Copy link
Member

@meatballs meatballs Dec 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely this has to be colourbar? 😉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I know it's called colorbar in matplotlib, but still.....)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear - I'm not actually asking for any change here.

@@ -284,6 +284,8 @@ def plot(self, col_map='seismic', interpolation='none', title=None):
http://matplotlib.org/examples/images_contours_and_fields/interpolation_methods.html
title : str, optional
A title for the plot
colorbar : bool, optional
Choose whether the colorbar should be included or not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

labels needs to be added here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also col_map and interpolation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

col_map and interpolation are already in there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agghh. sorry - that was github folding lines on me and I hadn't noticed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filename appears in the docstring but doesn't seem to be in the signature. Is that still required?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah, i've just got rid

plt.xticks([0, len(plotting_data) - 1], ['0', '1'])
plt.yticks([0, len(plotting_data) - 1], ['0', '1'])

if not labels:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test with labels=False and colorbar=False (just to check the plot runs).

@drvinceknight
Copy link
Member

Also, as the defaults are True (which I like) could you update the images for the docs?

Not sure if you saw that comment @theref

ticks = [min_score, (max_score + min_score) / 2, max_score]
fig.colorbar(cax, ticks=ticks)

plt.xlabel('y')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xlabel is 'y' and ylabel is 'x'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it's due to the way numpy shapes the data:
plotting_data = np.reshape(ordered_data, (size, size))
@drvinceknight do you think this is going to cause confusion? should I work on getting the plots rotated?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it's worth the change.

@marcharper
Copy link
Member

Just the one request for clarification from me.

@theref
Copy link
Member Author

theref commented Dec 7, 2016

A couple of examples:

screen shot 2016-12-07 at 09 14 00
screen shot 2016-12-07 at 09 14 13

@drvinceknight
Copy link
Member

This looks good, need to fix the conflicts with master and can you change x to $x$ (same for y) in the axis label.

@@ -284,6 +284,8 @@ def plot(self, col_map='seismic', interpolation='none', title=None):
http://matplotlib.org/examples/images_contours_and_fields/interpolation_methods.html
title : str, optional
A title for the plot
colorbar : bool, optional
Choose whether the colorbar should be included or not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also col_map and interpolation

plt.xlabel('$x$')
plt.ylabel('$y$', rotation=0)
# ax.xaxis.tick_top()
# ax.xaxis.set_label_position('top')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these two lines aren't required, can you get rid of them, please?

plt.ylabel('$y$', rotation=0)
# ax.xaxis.tick_top()
# ax.xaxis.set_label_position('top')
ax.tick_params(axis=u'both', which=u'both', length=0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for 'u' now as we no longer support Python 2

@drvinceknight
Copy link
Member

I'm happy.

@meatballs I suggest we wait till @marcharper wakes to merge, as all 3 of us have commented here now :)

@drvinceknight
Copy link
Member

@marcharper note that the examples in the conversation above are no longer correct, look at the files changed to see what they look like now :)

@marcharper marcharper merged commit 27a9bd4 into Axelrod-Python:master Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants