How to Add/Customize a Border (Outline) to Bar Charts
A week ago(245 views)
Hello JMP Community,
I would like to add an outline/border around each bar in a bar chart and customize its width. How can I achieve this in JMP?
As shown in the image below , I would like to add a border or outline around each bar.
I've heard of a workaround that involves overlaying two bar charts to simulate an outline. However, this method doesn't seem to allow for customization of the outline's width. Is there a way, either through the Graph Builder interface or by editing a script, to apply an outline to each bar and independently change its color and width?
I think using second bar chart should be ok solution, but it will require some work as you would have to create extra column to get heights correct and then modify width proportion. This has been done with that method
Here is exmple script you can run and then explore how the graph has been built (order of barcharts has been changed, width proportion is modified, color is changed and so on...)
@jthi has a good solution. I have a tendency to use the JMP graphic primitives that allow you to directly draw lines and rectangles with the ability to color and define thicknesses.
See Add Graphic Script in the Scripting Index and Scripting Guide for documentation and examples of how to do this.
Using Graphic Script. You have to know how many bars you have, and I think you cannot get that information from BarSeg object. So, it is easier to do with supporting marker added to graph (it can be hidden from final plot)
Use Marker Draw Expression. Does require adding marker, it is more difficult to implement, but is most likely more robust option
I don't have time to write-out these options now, but they do exist
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(656, 549),
Show Control Panel(0),
Variables(X(:age), Y(:height)),
Elements(
Bar(X, Y, Legend(4)),
Points(X, Y, Legend(5), Summary Statistic("Mean"))
),
SendToReport(
Dispatch({}, "400", ScaleBox,
{Legend Model(
5,
Type Properties(0, "Marker", {Transparency(0)}),
Properties(0, {Transparency(0)}, Item ID("Mean", 1))
)}
)
)
);
fb = Report(gb)[FrameBox(1)];
fb << Add Graphics Script(Function({this}, // can be laggy as it is a graphic script with a loop
ms = this << Find Seg(MarkerSeg(1));
xs = ms << Get X Values;
ys = ms << Get Y Values;
sideshift = 0.27;
For(i = 1, i <= N Items(xs), i++,
Pen Size(10); // Width of the line
Pen Color("Black");
Rect(xs[i] - sideshift, ys[i], xs[i] + sideshift, -1, 0);
);
));
And here is Marker Draw Expr
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(656, 549),
Show Control Panel(0),
Variables(X(:age), Y(:height)),
Elements(
Bar(X, Y, Legend(4)),
Points(X, Y, Legend(5), Summary Statistic("Mean"))
),
SendToReport(
Dispatch({}, "400", ScaleBox,
{Legend Model(
5,
Type Properties(0, "Marker", {Transparency(0)}),
Properties(0, Item ID("Mean", 1))
)}
)
)
);
fb = Report(gb)[FrameBox(1)];
seg = (fb << FindSeg(Marker Seg(1)));
seg << Set Marker Draw Expr(
Function({this seg, this row, x, y, size, row state},
Pen Size(10); // Width of the line
Pen Color("Black");
Rect(x - 0.27, y, x + 0.27, -1, 0);
)
);
The Marker Draw Expr example does not work correctly in my install of JMP 19. The Transparency default appears to be set to 0 for the marker. The below simple change allows for the rectangle to be displayed properly.
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(656, 549),
Show Control Panel(0),
Variables(X(:age), Y(:height)),
Elements(
Bar(X, Y, Legend(4)),
Points(X, Y, Legend(5), Summary Statistic("Mean"))
),
SendToReport(
Dispatch({}, "400", ScaleBox,
{Legend Model(
5,
Type Properties(0, "Marker", {Transparency(0)}),
Properties(0, Item ID("Mean", 1))
)}
)
)
);
fb = Report(gb)[FrameBox(1)];
seg = (fb << FindSeg(Marker Seg(1)));
seg << Set Marker Draw Expr(
Function({this seg, this row, x, y, size, row state},
show(x,y);
Pen Size(10); // Width of the line
Pen Color("Black");
transparency(1); // Needed for JMP 19
Rect(x - 0.27, y, x + 0.27, -1, 0);
)
);
Thank you so much for your detailed responses. It was very helpful. But there is one more thing I'd like to do.
When I use Set Marker Draw Expr to draw a bar border, it is drawn on the top layer. Consequently, when I add error bars or individual data points (via a dot plot), the custom border is drawn over them. Is there a way to control the drawing order (layer) of the border so that it appears behind the data points?
For highly customized graphing, do people typically use scripting languages like R, or dedicated software such as GraphPad Prism?
Re: How to Add/Customize a Border (Outline) to Bar Charts
Created:
Nov 16, 2025 10:07 AM
| Last Modified: Nov 16, 2025 7:09 AM(170 views)
| Posted in reply to message from Yo_ITO 11-16-2025
you can adjust the oder of the individual element: right click into the graph and change the order:
If there is just one plot type, just add 20 and customize them.
Graph Builder is orders of magnitude more flexible / powerful than people might think at first glance. This is the trick: a smooth transition from very easy drag and drop to highly customized graphs. With Set Marker Draw Expr you already got in tough with one very elaborate feature - but there are many more features. No need to use another plotting tool.
Draw your chart with the new borders and the error bars. Then right click on the graph and select Custom. It will bring up a dialog box where you can select the error bars and move them to the front. Close the dialog box and then go to the red triangle and select save script. You can then examine the script it produced and you will see what is necessary to move the error bars to the front using jsl.
Jim
Recommended Articles
'
var data = div.getElementsByClassName("video-js");
var script = document.createElement('script');
script.src = "https://players.brightcove.net/" + data_account + "/" + data_palyer + "_default/index.min.js";
for(var i=0;i< data.length;i++){
videodata.push(data[i]);
}
}
}
for(var i=0;i< videodata.length;i++){
document.getElementsByClassName('lia-vid-container')[i].innerHTML = videodata[i].outerHTML;
document.body.appendChild(script);
}
}
catch(e){
}
/* Re compile html */
$compile(rootElement.querySelectorAll('div.lia-message-body-content')[0])($scope);
}
if (code_l.toLowerCase() != newBody.getAttribute("slang").toLowerCase()) {
/* Adding Translation flag */
var tr_obj = $filter('filter')($scope.sourceLangList, function (obj_l) {
return obj_l.code.toLowerCase() === newBody.getAttribute("slang").toLowerCase()
});
if (tr_obj.length > 0) {
tr_text = "This post originally written in lilicon-trans-text has been computer translated for you. When you reply, it will also be translated back to lilicon-trans-text.".replace(/lilicon-trans-text/g, tr_obj[0].title);
try {
if ($scope.wootMessages[$rootScope.profLang] != undefined) {
tr_text = $scope.wootMessages[$rootScope.profLang].replace(/lilicon-trans-text/g, tr_obj[0].title);
}
} catch (e) {
}
} else {
//tr_text = "This message was translated for your convenience!";
tr_text = "This message was translated for your convenience!";
}
try {
if (!document.getElementById("tr-msz-" + value)) {
var tr_para = document.createElement("P");
tr_para.setAttribute("id", "tr-msz-" + value);
tr_para.setAttribute("class", "tr-msz");
tr_para.style.textAlign = 'justify';
var tr_fTag = document.createElement("IMG");
tr_fTag.setAttribute("class", "tFlag");
tr_fTag.setAttribute("src", "/html/assets/lingoTrFlag.PNG");
tr_fTag.style.marginRight = "5px";
tr_fTag.style.height = "14px";
tr_para.appendChild(tr_fTag);
var tr_textNode = document.createTextNode(tr_text);
tr_para.appendChild(tr_textNode);
/* Woot message only for multi source */
if(rootElement.querySelector(".lia-quilt-forum-message")){
rootElement.querySelector(".lia-quilt-forum-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-message-view-blog-topic-message")) {
rootElement.querySelector(".lia-message-view-blog-topic-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-quilt-blog-reply-message")){
rootElement.querySelector(".lia-quilt-blog-reply-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-quilt-tkb-message")){
rootElement.querySelector(".lia-quilt-tkb-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-quilt-tkb-reply-message")){
rootElement.querySelector(".lia-quilt-tkb-reply-message").insertBefore(tr_para,rootElement.querySelector(".lia-quilt-row.lia-quilt-row-footer"));
} else if(rootElement.querySelector(".lia-quilt-idea-message")){
rootElement.querySelector(".lia-quilt-idea-message").appendChild(tr_para);
} else if(rootElement.querySelector(".lia-quilt-idea-reply-message")){
rootElement.querySelector(".lia-quilt-idea-reply-message").insertBefore(tr_para,rootElement.querySelector(".lia-quilt-row.lia-quilt-row-footer"));
}else if(rootElement.querySelector(".lia-quilt-column-alley-left")){
rootElement.querySelector(".lia-quilt-column-alley-left").appendChild(tr_para);
}
else {
if (rootElement.querySelectorAll('div.lia-quilt-row-footer').length > 0) {
rootElement.querySelectorAll('div.lia-quilt-row-footer')[0].appendChild(tr_para);
} else {
rootElement.querySelectorAll('div.lia-quilt-column-message-footer')[0].appendChild(tr_para);
}
}
}
} catch (e) {
}
}
} else {
/* Do not display button for same language */
// syncList.remove(value);
var index = $scope.syncList.indexOf(value);
if (index > -1) {
$scope.syncList.splice(index, 1);
}
}
}
}
}
}
angular.forEach(mszList_l, function (value) {
if (document.querySelectorAll('div.lia-js-data-messageUid-' + value).length > 0) {
var rootElements = document.querySelectorAll('div.lia-js-data-messageUid-' + value);
}else if(document.querySelectorAll('.lia-occasion-message-view .lia-component-occasion-message-view').length >0){
var rootElements = document.querySelectorAll('.lia-occasion-message-view .lia-component-occasion-message-view')[0].querySelectorAll('.lia-occasion-description')[0];
}else {
var rootElements = document.querySelectorAll('div.message-uid-' + value);
}
angular.forEach(rootElements, function (rootElement) {
if (value == '913503' && "ForumTopicPage" == "TkbArticlePage") {
rootElement = document.querySelector('.lia-thread-topic');
}
/* V1.1 Remove from UI */
if (document.getElementById("tr-msz-" + value)) {
document.getElementById("tr-msz-" + value).remove();
}
if (document.getElementById("tr-sync-" + value)) {
document.getElementById("tr-sync-" + value).remove();
}
/* XPath expression for subject and Body */
var lingoRBExp = "//lingo-body[@id = " + "'lingo-body-" + value + "'" + "]";
lingoRSExp = "//lingo-sub[@id = " + "'lingo-sub-" + value + "'" + "]";
/* Get translated subject of the message */
lingoRSXML = doc.evaluate(lingoRSExp, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < lingoRSXML.snapshotLength; i++) {
/* Replace Reply/Comment subject with transalted subject */
var newSub = lingoRSXML.snapshotItem(i);
/*** START : extracting subject from source if selected language and source language is same **/
var sub_L = "";
if(newSub.getAttribute("slang").toLowerCase() == code_l.toLowerCase()) {
if(value == '913503') {
if($scope.sourceContent[value]){
if($scope.sourceContent[value].subject != ''){
sub_L = decodeURIComponent($scope.sourceContent[value].subject);
}
}else{
sub_L = newSub.innerHTML;
}
}
else{
sub_L = decodeURIComponent($scope.sourceContent[value].subject);
}
} else {
sub_L = newSub.innerHTML;
}
/*** End : extracting subject from source if selected language and source language is same **/
/* This code is placed to remove the extra meta tag adding in the UI*/
try{
sub_L = sub_L.replace('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />','');
}
catch(e){
}
// if($scope.viewTrContentOnly || (newSub.getAttribute("slang").toLowerCase() != code_l.toLowerCase())) {
if ($scope.viewTrContentOnly) {
if ("ForumTopicPage" == "IdeaPage") {
if (value == '913503') {
if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){
document.querySelector('.MessageSubject .lia-message-subject').innerHTML = sub_L;
}
}
}
if ("ForumTopicPage" == "TkbArticlePage") {
if (value == '913503') {
if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){
var subTkbElement = document.querySelector('.lia-thread-subject');
if(subTkbElement){
document.querySelector('.lia-thread-subject').innerHTML = sub_L;
}
}
}
}
else if ("ForumTopicPage" == "BlogArticlePage") {
if (value == '913503') {
try {
if((sub_L != "") && (sub_L!= undefined) && (sub_L != "undefined")){
var subElement = rootElement.querySelector('.lia-blog-article-page-article-subject');
if(subElement) {
subElement.innerText = sub_L;
}
}
} catch (e) {
}
/* var subElement = rootElement.querySelectorAll('.lia-blog-article-page-article-subject');
for (var subI = 0; subI < subElement.length; subI++) {
if((sub_L != "") && (sub_L!= undefined) && (sub_L != "undefined")){
subElement[subI].innerHTML = sub_L;
}
} */
}
else {
try {
// rootElement.querySelectorAll('.lia-blog-article-page-article-subject').innerHTML= sub_L;
/** var subElement = rootElement.querySelectorAll('.lia-blog-article-page-article-subject');
for (var j = 0; j < subElement.length; j++) {
if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){
subElement[j].innerHTML = sub_L;
}
} **/
} catch (e) {
}
}
}
else {
if (value == '913503') {
try{
/* Start: This code is written by iTalent as part of iTrack LILICON - 98 */
if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){
if(document.querySelectorAll('.lia-quilt-forum-topic-page').length > 0){
if(rootElement.querySelector('div.lia-message-subject').querySelector('h5')){
rootElement.querySelector('div.lia-message-subject').querySelector('h5').innerText = decodeURIComponent(sub_L);
} else {
rootElement.querySelector('.MessageSubject .lia-message-subject').innerText = sub_L;
}
} else {
rootElement.querySelector('.MessageSubject .lia-message-subject').innerText = sub_L;
}
}
/* End: This code is written by iTalent as part of iTrack LILICON - 98 */
}
catch(e){
console.log("subject not available for second time. error details: " + e);
}
} else {
try {
/* Start: This code is written by iTalent as part of LILICON - 98 reported by Ian */
if ("ForumTopicPage" == "IdeaPage") {
if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){
document.querySelector('.lia-js-data-messageUid-'+ value).querySelector('.MessageSubject .lia-message-subject').innerText = sub_L;
}
}
else{
if( (sub_L != "") && (sub_L != undefined) && (sub_L != "undefined") ){
rootElement.querySelector('.MessageSubject .lia-message-subject').innerText = sub_L;
/* End: This code is written as part of LILICON - 98 reported by Ian */
}
}
} catch (e) {
console.log("Reply subject not available. error details: " + e);
}
}
}
// Label translation
var labelEle = document.querySelector("#labelsForMessage");
if (!labelEle) {
labelEle = document.querySelector(".LabelsList");
}
if (labelEle) {
var listContains = labelEle.querySelector('.label');
if (listContains) {
/* Commenting this code as bussiness want to point search with source language label */
// var tagHLink = labelEle.querySelectorAll(".label")[0].querySelector(".label-link").href.split("label-name")[0];
var lingoLabelExp = "//lingo-label/text()";
trLabels = [];
trLabelsHtml = "";
/* Get translated labels of the message */
lingoLXML = doc.evaluate(lingoLabelExp, doc, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
/* try{
for(var j=0;j,';
}
trLabelsHtml = trLabelsHtml+'