Skip to content

Commit 430f16c

Browse files
author
minjk-bl
committed
Add countplot to Seaborn
1 parent e3c26b5 commit 430f16c

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

data/m_visualize/chartLibrary.js renamed to data/m_visualize/seabornLibrary.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ define([
1919
* }
2020
* ]
2121
*/
22-
var CHART_LIBRARIES = {
22+
var SEABORN_LIBRARIES = {
2323
/** Relational plots */
2424
'scatterplot': {
2525
name: 'Scatter Plot',
@@ -155,7 +155,19 @@ define([
155155
{ name: 'allocateTo', label: 'Allocate To', component: ['input'], usePair: true }
156156
]
157157
},
158+
'countplot': {
159+
name: 'Count Plot',
160+
code: '${allocateTo} = sns.countplot(${data}${x}${y}${hue}${etc})',
161+
description: 'Show the counts of observations in each categorical bin using bars.',
162+
options: [
163+
{ name: 'data', component: ['var_select'], var_type: ['DataFrame', 'Series', 'list'], usePair: true },
164+
{ name: 'x', component: ['col_select'], usePair: true },
165+
{ name: 'y', component: ['col_select'], usePair: true },
166+
{ name: 'hue', component: ['col_select'], usePair: true },
167+
{ name: 'allocateTo', label: 'Allocate To', component: ['input'], usePair: true }
168+
]
169+
}
158170
}
159171

160-
return CHART_LIBRARIES;
172+
return SEABORN_LIBRARIES;
161173
});

js/m_visualize/Seaborn.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ define([
2121
'vp_base/js/com/component/PopupComponent',
2222
'vp_base/js/com/component/SuggestInput',
2323
'vp_base/js/com/component/VarSelector2',
24-
'vp_base/data/m_visualize/chartLibrary'
25-
], function(chartHTml, chartCss, com_String, com_generator, com_util, PopupComponent, SuggestInput, VarSelector2, CHART_LIBRARIES) {
24+
'vp_base/data/m_visualize/seabornLibrary'
25+
], function(chartHTml, chartCss, com_String, com_generator, com_util, PopupComponent, SuggestInput, VarSelector2, SEABORN_LIBRARIES) {
2626

2727
class Seaborn extends PopupComponent {
2828
_init() {
@@ -67,12 +67,12 @@ define([
6767
...this.state
6868
}
6969

70-
this.chartConfig = CHART_LIBRARIES;
70+
this.chartConfig = SEABORN_LIBRARIES;
7171
this.chartTypeList = {
7272
'Relational': [ 'scatterplot', 'lineplot' ],
7373
'Distributions': [ 'histplot', 'kdeplot', 'rugplot' ],
7474
'Categorical': [ 'stripplot', 'swarmplot', 'boxplot', 'violinplot', 'pointplot', 'barplot' ],
75-
// 'ETC': [ ]
75+
'ETC': [ 'countplot' ]
7676
}
7777

7878
this.legendPosList = [

0 commit comments

Comments
 (0)