Skip to content

Commit 311313b

Browse files
author
minjk-bl
committed
Add errorbar option for line, barplot on Seaborn
1 parent 534a18c commit 311313b

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

visualpython/html/m_visualize/seaborn.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,18 @@
231231
<label for="showValuesPrecision">Decimal place</label>
232232
<input type="number" id="showValuesPrecision" class="vp-state" placeholder="Type decimal places(0~5)" min="0" max="5"/>
233233
</div>
234+
</div>
235+
<div class="vp-grid-box sb-option">
236+
<hr style="margin:5px;"/>
237+
<label class="vp-bold">Errorbar</label>
238+
<input type="text" id="errorbar" class="vp-input vp-state" placeholder="('ci', 95)"/>
234239
<hr style="margin:5px;"/>
235240
</div>
236241
<label for="useLegend" class="vp-bold">Legend</label>
237242
<div class="vp-grid-col-p50">
238243
<select id="legendPos" class="vp-select vp-state">
239244
<!-- Legend Position FIXME: -->
240-
245+
241246
</select>
242247
</div>
243248
</div>

visualpython/js/m_visualize/Seaborn.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ define([
5353
stat: '',
5454
showValues: false,
5555
showValuesPrecision: '',
56+
errorbar: '',
5657
sortBy: 'y',
5758
sortType: '',
5859
sortHue: '',
@@ -201,6 +202,7 @@ define([
201202
$(that.wrapSelector('#stat')).closest('.sb-option').show();
202203
} else if (chartType == 'barplot') {
203204
$(that.wrapSelector('#showValues')).closest('.sb-option').show();
205+
$(that.wrapSelector('#errorbar')).closest('.sb-option').show();
204206
if (that.state.setXY === false) {
205207
if (that.state.x !== '' && that.state.y !== '') {
206208
$(that.wrapSelector('#sortBy')).closest('.sb-option').show();
@@ -221,6 +223,8 @@ define([
221223
}
222224
} else if (chartType == 'heatmap') {
223225
$(that.wrapSelector('#annot')).closest('.sb-option').show();
226+
} else if (chartType === 'lineplot') {
227+
$(that.wrapSelector('#errorbar')).closest('.sb-option').show();
224228
}
225229
});
226230

@@ -527,6 +531,15 @@ define([
527531
});
528532
$(page).find('#sampleCount').html(sampleCountTag.toString());
529533

534+
// set errorbar list
535+
var vpErrorbarSuggest = new SuggestInput();
536+
vpErrorbarSuggest.setComponentID('errorbar');
537+
vpErrorbarSuggest.addClass('vp-input vp-state');
538+
vpErrorbarSuggest.setPlaceholder("('ci', 95)");
539+
vpErrorbarSuggest.setValue(this.state.errorbar);
540+
vpErrorbarSuggest.setSuggestList(["None", "'ci'", "'pi'", "'sd'", "'se'"]);
541+
$(page).find('#errorbar').replaceWith(vpErrorbarSuggest.toTagString());
542+
530543
// data options depend on chart type
531544
$(page).find('.sb-option').hide();
532545
if (this.state.chartType == 'histplot') {
@@ -535,6 +548,7 @@ define([
535548
$(page).find('#stat').closest('.sb-option').show();
536549
} else if (this.state.chartType == 'barplot') {
537550
$(page).find('#showValues').closest('.sb-option').show();
551+
$(page).find('#errorbar').closest('.sb-option').show();
538552
if (this.state.setXY === false) {
539553
if (this.state.x !== '' && this.state.y !== '') {
540554
$(page).find('#sortBy').closest('.sb-option').show();
@@ -555,6 +569,8 @@ define([
555569
}
556570
} else if (this.state.chartType == 'heatmap') {
557571
$(page).find('#annot').closest('.sb-option').show();
572+
} else if (this.state.chartType === 'lineplot') {
573+
$(page).find('#errorbar').closest('.sb-option').show();
558574
}
559575

560576
//================================================================
@@ -875,7 +891,7 @@ define([
875891
generateCode(preview=false) {
876892
let {
877893
chartType, data, x, y, setXY, hue, kde, stat,
878-
showValues, showValuesPrecision,
894+
showValues, showValuesPrecision, errorbar,
879895
sortType, sortBy, sortHue, sortHueText,
880896
userOption='',
881897
x_limit_from, x_limit_to, y_limit_from, y_limit_to,
@@ -940,6 +956,12 @@ define([
940956
if (showValues === true && chartType === 'barplot') {
941957
// etcOptionCode.push('ci=None'); // changed to errorbar after 0.12 version
942958
etcOptionCode.push('errorbar=None');
959+
} else {
960+
if (chartType === 'barplot' || chartType === 'lineplot') {
961+
if (errorbar !== '') {
962+
etcOptionCode.push(com_util.formatString("errorbar={0}", errorbar));
963+
}
964+
}
943965
}
944966
if (setXY === false && sortType !== '') {
945967
let sortCode = '';

0 commit comments

Comments
 (0)