Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Distplot #275

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 19 commits into from
Sep 17, 2015
Merged

Distplot #275

merged 19 commits into from
Sep 17, 2015

Conversation

cldougl
Copy link
Member

@cldougl cldougl commented Aug 5, 2015

  • add distplot to FigureFactory
  • add validate_displot() method to tools.py
  • add core tests for distplot parameters

cldougl added 9 commits August 4, 2015 17:58
- Plotly version of seaborn.distplot to add to FigureFactory
- plots histogram, curve (kde or normal), and rugplot
- add `validate_displot()` method to tools.py
- add core tests for distplot parameters
- add protected import of scipy to tools.py
- add distplot checks to tests_optional
- add scipy.stats
- edit examples in docstring
- all distplot tests are depending on scipy
@cldougl
Copy link
Member Author

cldougl commented Aug 5, 2015

@chriddyp @theengineear @aneda @etpinard
Hey everyone, here's a draft of the distplot (http://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.distplot.html) FigureFactory addition.
One issue though - I'm not sure if the 'protected import' of scipy I tried is how we want to add it / correct in general- the tests won't pass on circle.

@chriddyp
Copy link
Member

chriddyp commented Aug 6, 2015

@cldougl from the Circle error:

======================================================================
ERROR: test_distplot_more_args (plotly.tests.test_optional.test_opt_tracefactory.TestDistplot)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/python-api/plotly/tests/test_optional/test_opt_tracefactory.py", line 109, in test_distplot_more_args
    show_rug=False, bin_size=.2)
  File "/home/ubuntu/python-api/plotly/tools.py", line 2418, in create_distplot
    FigureFactory.validate_distplot(hist_data, curve_type)
  File "/home/ubuntu/python-api/plotly/tools.py", line 1541, in validate_distplot
    raise ImportError("FigureFactory.create_distplot requires scipy")
ImportError: FigureFactory.create_distplot requires scipy

it looks like our Circle build doesn't have scipy. Circle will only build the packages that we explicitly configure. Here is the circle configuration file: https://github.com/plotly/python-api/blob/master/circle.yml#L7, note the "optional-requirements.txt" reference. if you add scipy to that file: https://github.com/plotly/python-api/blob/master/optional-requirements.txt, then circle should build it and tests should pass

@cldougl
Copy link
Member Author

cldougl commented Aug 6, 2015

ahh thank you @chriddyp !!

_scipy_imported = True
except ImportError:
_scipy_imported = False

Copy link
Contributor

Choose a reason for hiding this comment

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

\o/

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this is going to be a merge conflict with #274 . I guess we'll need to have some specific requirements specified... How about a syntax like:

_scipy_imported
_scipy__spatial_imported
_scipy__cluster__hierarchy_imported

I'm not sure which is going to land first, but the latter will have to implement this.

cldougl added 2 commits August 7, 2015 13:10
- DRYing type validation
- fix over-indentation
"rgb(227, 119, 194)", "rgb(127, 127, 127)",
"rgb(188, 189, 34)", "rgb(23, 190, 207)"]
self.curve_x = [None]*self.trace_number
self.curve_y = [None]*self.trace_number
Copy link
Contributor

Choose a reason for hiding this comment

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

pep:8ball: spaces around operators

@theengineear
Copy link
Contributor

@cldougl awesome! I'm ok with 💃 this. I'd like to let @chriddyp check over it again too though.

@@ -1501,6 +1508,35 @@ def validate_ohlc(open, high, low, close, direction, **kwargs):
"'both'")

@staticmethod
def validate_distplot(hist_data, curve_type):
Copy link
Member

Choose a reason for hiding this comment

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

can we make these guys hidden? (by adding a _). there's hardly anything I like more than seeing the minimal number of functions in the ipython tab-tab helper:
image

zeroline=False),
yaxis1=dict(domain=[0., 1],
anchor='free',
position=0.0))
Copy link
Member

Choose a reason for hiding this comment

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

Could we reverse the legend? That way way the rugs will be displayed in the same order as the legend entries. Right now they're in opposite orders
image

@chriddyp
Copy link
Member

otherwise, sweet!

- hide validate functions from tab-tab helper
- add pandas example and pandas type to validation
- replace `**kwargs` with `rug_text` and `colors` in
- updated the docstring with Andrew’s nice terse suggestions
- hid tick label from rug plot
- modified rug_text so its indexed across datasets, not copied
- edited examples
  - added import numpy where needed
  - increased sample sizes
- reversed legend
- fix the show_legend issue so a legend is shown if the hist is hidden
- add test to test_core to check exception for `scipy_import = False`
- edit tests in test optional to reflect the changes (mentioned above)
made
- scipy will currently import in test_core
@cldougl
Copy link
Member Author

cldougl commented Sep 14, 2015

@chriddyp can I merge this?

@chriddyp
Copy link
Member

Looking good! It doesn't look like the colors argument is working for me:

import plotly.plotly as py
from plotly.tools import FigureFactory as FF
import numpy as np

x1 = np.random.randn(200)
x2 = np.random.randn(200)+1
x3 = np.random.randn(200)-1
x4 = np.random.randn(200)+2

hist_data = [x1] + [x2] + [x3] + [x4]
group_labels = ['2012', '2013', '2014', '2015']

fig = FF.create_distplot(
    hist_data, group_labels, curve_type='normal',
    bin_size=.2, colors=['yellow', 'pink', 'grey', 'aqua'])

iplot(fig)

image

@chriddyp
Copy link
Member

Thx for fixing! All good by me now 💃 Can you add some python examples as ipython notebooks to /documentation?

@cldougl
Copy link
Member Author

cldougl commented Sep 17, 2015

Thanks! yep doc's ready

cldougl added a commit that referenced this pull request Sep 17, 2015
@cldougl cldougl merged commit 2a22483 into master Sep 17, 2015
@theengineear theengineear deleted the distplot branch September 30, 2015 06:13
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.

3 participants