-
Notifications
You must be signed in to change notification settings - Fork 49
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
Corr plot module #220
Merged
Merged
Corr plot module #220
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
f61a696
fillDiagonal in correlation utils
IKrukov-HORIS 8d5253b
corr.py module
IKrukov-HORIS 879af8a
Removed format parameter
IKrukov-HORIS fd3d999
Removed _get_format method
IKrukov-HORIS 6927fcd
_tooltip_spec without format parameter
IKrukov-HORIS 4c079ab
flip = True by default
IKrukov-HORIS d1240b5
flip = True by default
IKrukov-HORIS 53912e8
flip = True by default
IKrukov-HORIS 04bbd2b
_set_diverging_palette renamed to _set_brewer_palette
IKrukov-HORIS 791deef
Using API in build
IKrukov-HORIS 9e6e822
Removed div arg
IKrukov-HORIS 2d0eee9
layers creation deferred till build
IKrukov-HORIS 6dbfcbd
Legend change: Correlation -> Corr
IKrukov-HORIS 4e74f4c
Add fill_scale
IKrukov-HORIS 0f51ad7
tiles implemented via geom_tile
IKrukov-HORIS f3495e0
Fixed tile implementation.
IKrukov-HORIS 8e4c8e5
Fix height calculation
IKrukov-HORIS 3aabfeb
coord_cartesian when tiles layer is active
IKrukov-HORIS 84d893f
tiles width / height = 0.99
IKrukov-HORIS 663666c
Additive expand 0.5
IKrukov-HORIS 0116ad0
Set fill_diagonal in StatProto
IKrukov-HORIS 7b240e9
Change parameter passing way and some defaults
IKrukov-HORIS 35dda1e
correlation matrix examples
IKrukov-HORIS 709fe1b
Fix typo in methods names
IKrukov-HORIS ce6aac2
Fix typo in demo
IKrukov-HORIS 25c24b5
Demo layout fix
IKrukov-HORIS f821be6
brewer palette legend fix
IKrukov-HORIS 80deb81
brewer palette legend fix in demo
IKrukov-HORIS 6eb36e8
brewer palette example update
IKrukov-HORIS 206be8f
add scale_fill_identity for tiles na values
IKrukov-HORIS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Removed format parameter
- Loading branch information
commit 879af8a13624d315fc88b7fb9f2f0adea8bf1b45
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,24 +32,21 @@ class corr_plot_builder: | |
This class is intended to build correlation matrix plots. | ||
""" | ||
|
||
def __init__(self, data, show_legend=None, format=None, flip=None): | ||
def __init__(self, data, show_legend=None, flip=None): | ||
""" | ||
Parameters | ||
---------- | ||
data : dictionary or pandas DataFrame | ||
Correlation will be calculated for each variable pair. | ||
show_legend : Boolean | ||
If True legend is shown. Default - True. | ||
format : string | ||
The format to apply to the field. The format contains a number format (1.f) or a string template ({.1f}). | ||
Default - '.2f'. | ||
flip : Boolean | ||
If True the y axis is flipped. | ||
""" | ||
|
||
self._data = data | ||
self._show_legend = show_legend | ||
self._format = format if format else '.2f' | ||
self._format = '.2f' | ||
self._reverse_y = flip if flip else False | ||
self._text_color = None | ||
self._tiles_layer = None | ||
|
@@ -60,7 +57,7 @@ def __init__(self, data, show_legend=None, format=None, flip=None): | |
breaks=[-1.0, -0.5, 0.0, 0.5, 1.0], | ||
limits=[-1.0, 1.0]) | ||
|
||
def points(self, type=None, fill_diagonal=None, format=None): | ||
def points(self, type=None, fill_diagonal=None): | ||
""" | ||
Method defines correlation matrix layer drawn by points to the plot. | ||
|
||
|
@@ -70,22 +67,19 @@ def points(self, type=None, fill_diagonal=None, format=None): | |
Type of matrix. Possible values - "upper", "lower", "full". Default - "full". | ||
fill_diagonal : Boolean | ||
If True the main diagonal is filled with values. Default - True. | ||
format : string | ||
The format to apply to the field. The format contains a number format (1.f) or a string template ({.1f}). | ||
Default - '.2f'. | ||
|
||
Returns | ||
------- | ||
self | ||
""" | ||
|
||
self._points_layer = geom_point(stat='corr', show_legend=self._show_legend, size_unit='x', | ||
tooltips=self._tooltip_spec(format), | ||
tooltips=self._tooltip_spec(None), | ||
type=self._get_type(type), fill_diagonal=fill_diagonal) | ||
|
||
return self | ||
|
||
def labels(self, type=None, fill_diagonal=None, format=None, map_size=False, color=None): | ||
def labels(self, type=None, fill_diagonal=None, map_size=False, color=None): | ||
""" | ||
Method defines correlation matrix layer drawn with geom_text to the plot. | ||
|
||
|
@@ -95,9 +89,6 @@ def labels(self, type=None, fill_diagonal=None, format=None, map_size=False, col | |
Type of matrix. Possible values - "upper", "lower", "full". Default - "full". | ||
fill_diagonal : Boolean | ||
If True the main diagonal is filled with values. Default - True. | ||
format : string | ||
The format to apply to the field. The format contains a number format (1.f) or a string template ({.1f}). | ||
Default - '.2f'. | ||
map_size : Boolean | ||
If True, then absolute value of correlation is mapped to text size. Default - False. | ||
color: string | ||
|
@@ -118,14 +109,14 @@ def labels(self, type=None, fill_diagonal=None, format=None, map_size=False, col | |
other_args['color'] = self._text_color | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens with text's color if user adds 'tiles' after 'labels'? |
||
|
||
self._labels_layer = geom_text(stat='corr', show_legend=self._show_legend, | ||
tooltips=self._tooltip_spec(format), | ||
tooltips=self._tooltip_spec(None), | ||
type=self._get_type(type), fill_diagonal=fill_diagonal, | ||
na_value='', label_format=self._get_format(format), | ||
na_value='', label_format=self._get_format(None), | ||
size_unit = 'x', **other_args) | ||
|
||
return self | ||
|
||
def tiles(self, type=None, fill_diagonal=None, format=None): | ||
def tiles(self, type=None, fill_diagonal=None): | ||
""" | ||
Method defines correlation matrix layer drawn as square tiles to the plot. | ||
|
||
|
@@ -135,9 +126,6 @@ def tiles(self, type=None, fill_diagonal=None, format=None): | |
Type of matrix. Possible values - "upper", "lower", "full". Default - "full". | ||
fill_diagonal : Boolean | ||
If True the main diagonal is filled with values. Default - True. | ||
format : string | ||
The format to apply to the field. The format contains a number format (1.f) or a string template ({.1f}). | ||
Default - '.2f'. | ||
|
||
Returns | ||
------- | ||
|
@@ -147,7 +135,7 @@ def tiles(self, type=None, fill_diagonal=None, format=None): | |
self._text_color = 'white' | ||
|
||
self._tiles_layer = geom_point(stat='corr', show_legend=self._show_legend, size_unit='x', | ||
tooltips=self._tooltip_spec(format), | ||
tooltips=self._tooltip_spec(None), | ||
type=self._get_type(type), fill_diagonal=fill_diagonal, | ||
size=1.0, shape=15) | ||
|
||
|
@@ -372,17 +360,14 @@ def _set_diverging_palette(self, palette): | |
return self | ||
|
||
|
||
def corr_plot_scatter(data, format=None, palette=None): | ||
def corr_plot_scatter(data, palette=None): | ||
""" | ||
Draws correlation matrix as scatterplot. | ||
|
||
Parameters | ||
---------- | ||
data : dictionary or pandas DataFrame. | ||
Correlation will be calculated for each variable pair. Required. | ||
format : string | ||
The format to apply to the field. The format contains a number format (1.f) or a string template ({.1f}). | ||
Default - '.2f'. | ||
palette : string | ||
Palette name, one of: "BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral". | ||
|
||
|
@@ -391,7 +376,7 @@ def corr_plot_scatter(data, format=None, palette=None): | |
PlotSpec for correlation matrix. | ||
""" | ||
|
||
plot_builder = corr_plot_builder(data=data, format=format, flip=True) | ||
plot_builder = corr_plot_builder(data=data, flip=True) | ||
plot_builder.points() | ||
|
||
if palette: | ||
|
@@ -400,25 +385,22 @@ def corr_plot_scatter(data, format=None, palette=None): | |
return plot_builder.build() | ||
|
||
|
||
def corr_plot_tiles(data, format=None, palette=None): | ||
def corr_plot_tiles(data, palette=None): | ||
""" | ||
Draws correlation matrix as tiles. | ||
|
||
Parameters | ||
---------- | ||
data : dictionary or pandas DataFrame. | ||
Correlation will be calculated for each variable pair. Required. | ||
format : string | ||
The format to apply to the field. The format contains a number format (1.f) or a string template ({.1f}). | ||
Default - '.2f'. | ||
palette : string | ||
Palette name, one of: "BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral". | ||
|
||
Returns | ||
------- | ||
PlotSpec for correlation matrix. | ||
""" | ||
plot_builder = corr_plot_builder(data=data, format=format, flip=True) | ||
plot_builder = corr_plot_builder(data=data,flip=True) | ||
plot_builder.tiles() | ||
|
||
if palette: | ||
|
@@ -427,25 +409,22 @@ def corr_plot_tiles(data, format=None, palette=None): | |
return plot_builder.build() | ||
|
||
|
||
def corr_plot_tileslab(data, format=None, palette=None): | ||
def corr_plot_tileslab(data, palette=None): | ||
""" | ||
Draws correlation matrix as tiles with labels. | ||
|
||
Parameters | ||
---------- | ||
data : dictionary or pandas DataFrame. | ||
Correlation will be calculated for each variable pair. Required. | ||
format : string | ||
The format to apply to the field. The format contains a number format (1.f) or a string template ({.1f}). | ||
Default - '.2f'. | ||
palette : string | ||
Palette name, one of: "BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral". | ||
|
||
Returns | ||
------- | ||
PlotSpec for correlation matrix. | ||
""" | ||
plot_builder = corr_plot_builder(data=data, format=format, flip=True) | ||
plot_builder = corr_plot_builder(data=data, flip=True) | ||
plot_builder.tiles() | ||
plot_builder.labels() | ||
|
||
|
@@ -455,25 +434,22 @@ def corr_plot_tileslab(data, format=None, palette=None): | |
return plot_builder.build() | ||
|
||
|
||
def corr_plot_scatterlab(data, format=None, palette=None): | ||
def corr_plot_scatterlab(data, palette=None): | ||
""" | ||
Draws correlation matrix as mix of scattrplot and labels. | ||
|
||
Parameters | ||
---------- | ||
data : dictionary or pandas DataFrame. | ||
Correlation will be calculated for each variable pair. Required. | ||
format : string | ||
The format to apply to the field. The format contains a number format (1.f) or a string template ({.1f}). | ||
Default - '.2f'. | ||
palette : string | ||
Palette name, one of: "BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral". | ||
|
||
Returns | ||
------- | ||
PlotSpec for correlation matrix. | ||
""" | ||
plot_builder = corr_plot_builder(data=data, format=format, flip=True) | ||
plot_builder = corr_plot_builder(data=data, flip=True) | ||
plot_builder.points(type='lower') | ||
plot_builder.labels(type='upper', fill_diagonal=False, map_size=False) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets's have: flip=True