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

Skip to content

[2.0.0] Relocate figure factory #652

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 4 commits into from
Jan 9, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Some pep:8ball: changes.
Ok the changes in default args are more than style changes… Just a heads
up.
  • Loading branch information
theengineear committed Jan 6, 2017
commit bcb6da0bf360043b793300d82de9b82f56d19d7d
19 changes: 13 additions & 6 deletions plotly/figure_factory/_dendrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ def create_dendrogram(X, orientation="bottom", labels=None,
:param (str) orientation: 'top', 'right', 'bottom', or 'left'
:param (list) labels: List of axis category labels(observation labels)
:param (list) colorscale: Optional colorscale for dendrogram tree
:param (function) distfun: Function to compute the pairwise distance from the observations
:param (function) linkagefun: Function to compute the linkage matrix from the pairwise distances
:param (function) distfun: Function to compute the pairwise distance from
the observations
:param (function) linkagefun: Function to compute the linkage matrix from
the pairwise distances

clusters

Expand Down Expand Up @@ -106,7 +108,8 @@ class _Dendrogram(object):

def __init__(self, X, orientation='bottom', labels=None, colorscale=None,
width="100%", height="100%", xaxis='xaxis', yaxis='yaxis',
distfun=None, linkagefun=lambda x: sch.linkage(x, 'complete')):
distfun=None,
linkagefun=lambda x: sch.linkage(x, 'complete')):
self.orientation = orientation
self.labels = labels
self.xaxis = xaxis
Expand All @@ -130,7 +133,9 @@ def __init__(self, X, orientation='bottom', labels=None, colorscale=None,
distfun = scs.distance.pdist

(dd_traces, xvals, yvals,
ordered_labels, leaves) = self.get_dendrogram_traces(X, colorscale, distfun, linkagefun)
ordered_labels, leaves) = self.get_dendrogram_traces(X, colorscale,
distfun,
linkagefun)

self.labels = ordered_labels
self.leaves = leaves
Expand Down Expand Up @@ -245,8 +250,10 @@ def get_dendrogram_traces(self, X, colorscale, distfun, linkagefun):

:param (ndarray) X: Matrix of observations as array of arrays
:param (list) colorscale: Color scale for dendrogram tree clusters
:param (function) distfun: Function to compute the pairwise distance from the observations
:param (function) linkagefun: Function to compute the linkage matrix from the pairwise distances
:param (function) distfun: Function to compute the pairwise distance
from the observations
:param (function) linkagefun: Function to compute the linkage matrix
from the pairwise distances
:rtype (tuple): Contains all the traces in the following order:
(a) trace_list: List of Plotly trace objects for dendrogram tree
(b) icoord: All X points of the dendrogram tree as array of arrays
Expand Down
7 changes: 6 additions & 1 deletion plotly/figure_factory/_distplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def validate_distplot(hist_data, curve_type):


def create_distplot(hist_data, group_labels, bin_size=1., curve_type='kde',
colors=[], rug_text=[], histnorm=DEFAULT_HISTNORM,
colors=None, rug_text=None, histnorm=DEFAULT_HISTNORM,
show_hist=True, show_curve=True, show_rug=True):
"""
BETA function that creates a distplot similar to seaborn.distplot
Expand Down Expand Up @@ -169,6 +169,11 @@ def create_distplot(hist_data, group_labels, bin_size=1., curve_type='kde',
validate=False)
```
"""
if colors is None:
colors = []
if rug_text is None:
rug_text = []

validate_distplot(hist_data, curve_type)
utils.validate_equal_length(hist_data, group_labels)

Expand Down
9 changes: 3 additions & 6 deletions plotly/figure_factory/_gantt.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ def gantt(chart, colors, title, bar_width, showgrid_x, showgrid_y, height,
'opacity': 1,
'line': {
'width': 0,
},
'yref': 'y',
}
}
# create the list of task names
for index in range(len(tasks)):
Expand Down Expand Up @@ -206,8 +205,7 @@ def gantt_colorscale(chart, colors, title, index_col, show_colorbar, bar_width,
'opacity': 1,
'line': {
'width': 0,
},
'yref': 'y',
}
}

# compute the color for task based on indexing column
Expand Down Expand Up @@ -455,8 +453,7 @@ def gantt_dict(chart, colors, title, index_col, show_colorbar, bar_width,
'opacity': 1,
'line': {
'width': 0,
},
'yref': 'y',
}
}

index_vals = []
Expand Down
4 changes: 3 additions & 1 deletion plotly/figure_factory/_trisurf.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def create_trisurf(x, y, z, simplices, colormap=None, show_colorbar=True,
zerolinecolor='rgb(255, 255, 255)',
edges_color='rgb(50, 50, 50)',
height=800, width=800,
aspectratio=dict(x=1, y=1, z=1)):
aspectratio=None):
"""
Returns figure for a triangulated surface plot

Expand Down Expand Up @@ -452,6 +452,8 @@ def dist_origin(x, y, z):
py.iplot(fig, filename="trisurf-plot-modern-art")
```
"""
if aspectratio is None:
aspectratio = {'x': 1, 'y': 1, 'z': 1}

# Validate colormap
colors.validate_colors(colormap)
Expand Down