Added axis keyword to dendrogram function #3201

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

jamestwebber commented Jan 10, 2014

This fixes issue #1325 (Trac 798). It allows scipy dendrograms to easily be plotted on custom axes, e.g. as part of a larger figure. It does not import pylab at all if an axis is provided, which is useful for those who are using the matplotlib API.

Added axis keyword to dendrogram function
This fixes issue 1325 (Trac #798). It allows scipy dendrograms to easily be plotted on custom axes, e.g. as part of a larger figure. It does not import pylab at all if an axis is provided, which is useful for those who are using the matplotlib API.
Owner

rgommers commented Jan 12, 2014

Overall this looks like a good idea. A couple of comments:

The axis argument should be named ax, because that's how this argument is typically called. axis normally means the axis of the input array over which to apply a certain operation (np.mean(x, axis=1)).

A test should be added for this keyword. Matplotlib is an optional dependency, so the test should only run if MPL is installed. You can look at the stats.probplot test as an example for how to add such a test:
https://github.com/scipy/scipy/blob/master/scipy/stats/tests/test_morestats.py#L17
https://github.com/scipy/scipy/blob/master/scipy/stats/tests/test_morestats.py#L436

Owner

rgommers commented Jan 12, 2014

TravisCI failure is unrelated, can be ignored.

Contributor

jamestwebber commented Jan 12, 2014

Changing from axis to ax is easy enough to do. 'axis' was used throughout the existing code so I went with it.

I wasn't sure how to test a plot, it looks like (in the example you pointed me to) there's no test for the correct output, just to make sure it doesn't fail? I can add that to the existing cluster tests.

Changed 'axis' to 'ax' throughout dendrogram code
Also changed "axis_gca" flag to be more descriptive "trigger_redraw".
Owner

rgommers commented Jan 12, 2014

Indeed, checking that it doesn't fail. Comparing graphics output is done by the MPL test suite, but is hard and overkill here.

Added test for dendrogram plotting
Tests plotting to pylab.gca() and to an axis passed in as an argument.
Contributor

jamestwebber commented Jan 12, 2014

The interface for dendrogram is slightly different than the one for probplot (and it seems out of scope to try to change that). I didn't compare the output of the two different calls because there isn't the option to pass in pyplot instead of an axis.

Coverage Status

Changes Unknown when pulling d229aa3 on jamestwebber:patch-1 into * on scipy:master*.

Coverage Status

Changes Unknown when pulling d229aa3 on jamestwebber:patch-1 into * on scipy:master*.

Coverage Status

Changes Unknown when pulling bf2ec22 on jamestwebber:patch-1 into * on scipy:master*.

rgommers added a commit that referenced this pull request Jan 18, 2014

Owner

rgommers commented Jan 18, 2014

Test and doc addition look good. PR merged in dc7555b. Thanks @jamestwebber

@rgommers rgommers closed this Jan 18, 2014

Owner

rgommers commented Jan 18, 2014

Note that I did edit your commit messages to prepend the standard abbreviations listed at http://docs.scipy.org/doc/numpy-dev/dev/gitwash/development_workflow.html#writing-the-commit-message.

@jamestwebber jamestwebber deleted the jamestwebber:patch-1 branch Jan 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment