Issue
The clustermap returns a clustergrid, I want to know all the option I could add behind the clustergrid 'g' as the code showed below. I could not found the detailed documentation in seaborn. Does anybody could help?
import seaborn as sns
import matplotlib.pyplot as plt
iris = sns.load_dataset("iris")
g = sns.clustermap(iris, col_cluster=False, yticklabels=False)
g.cax.set_position([.15, .2, .03, .45])
g.ax_heatmap.XXX
Solution
There are tools to get information of objects in Python. Part of the problem is that your code gets hung up at the creation of g
, (which of course is maybe why you want documentation!). But using the example from the seaborn
docs:
import seaborn as sns; sns.set(color_codes=True)
iris = sns.load_dataset("iris")
species = iris.pop("species")
g = sns.clustermap(iris)
You can do dir(g)
to get all its attributes:
['__class__',
'__delattr__',
'__dict__',
'__dir__',
'__doc__',
...
'row_colors',
'savefig',
'set',
'standard_scale',
'z_score']
You can also call help(g)
to get the docstring for ClusterGrid
:
class ClusterGrid(seaborn.axisgrid.Grid)
| ClusterGrid(data, pivot_kws=None, z_score=None, standard_scale=None, figsize=None, row_colors=None, col_colors=None, mask=None)
|
| Base class for grids of subplots.
|
| Method resolution order:
| ClusterGrid
| seaborn.axisgrid.Grid
| builtins.object
|
| Methods defined here:
...
...
...
You can use type(g)
to get the full object type:
seaborn.matrix.ClusterGrid
Which can show you the path through the seaborn
source to get its definition here.
You could also use the built-in inspect
module to get more information for seaborn.matrix.ClusterGrid
.
>>>print(inspect.getsource(seaborn.matrix.ClusterGrid)) #for getting source code
class ClusterGrid(Grid):
def __init__(self, data, pivot_kws=None, z_score=None, standard_scale=None,
figsize=None, row_colors=None, col_colors=None, mask=None):
"""Grid object for organizing clustered heatmap input on to axes"""
...
...
...
>>>print(inspect.getfullargspec(seaborn.matrix.ClusterGrid)) #for getting arguments
FullArgSpec(args=['self', 'data', 'pivot_kws', 'z_score', 'standard_scale', 'figsize', 'row_colors', 'col_colors', 'mask'], varargs=None, varkw=None, defaults=(None, None, None, None, None, None, None), kwonlyargs=[], kwonlydefaults=None, annotations={})
I also cannot find online documentation for the record.
Answered By - Tom
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.