- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Change color any line of boxplot
How can I change the color of a specific line in a boxplot in JMP, similar to how it's done in SPSS
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Change color any line of boxplot
Hi @thiennguyen ,
I'm not sure that it's possible to do that in JMP -- at least to modify the color of any possible line in a box plot.
I played around with the Air.jmp sample data table using :Ozon cencentration and :month as the y and x axes, respectively. You can modify the color of any one box plot and its whiskers, but I don't think you can do that to any one line element of the box plot -- that is unless you build the box plot lines individually and manually create the box plot, which kind of defeats the purpose of using JMP's graphing capabilities.
One of the reasons I think it's not possible is how the box plot is addressed in the JSL version:
Graph Builder(
Graph Spacing( 4 ),
Variables( X( :month ), Y( :Ozone Concentration ) ),
Elements( Box Plot( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{DispatchSeg(
Box Plot Seg( "Box Plot (1)" ),
{Confidence Diamond( 1 ), Shortest Half Bracket( 1 ),
Line Color( "Blue" )}
)}
)
)
);
If you read down the JSL to the Box Plot Seg() command, it is accessing the entire "Box Plot (1)" element as a whole, not an individual line segment. I also checked the tree structure of the graph builder, and it looks like it treats the box plot elements as an entire entity.
Based on this, I don't see a way at the moment to access a single line segment of a box plot and make it a unique color. Sorry it's not a real solution to your question.
Hope this helps,
DS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Change color any line of boxplot
Hi @thiennguyen ,
Sorry, can't help much there. I'm not familiar with how to do it in SPSS, R or Python. As I mentioned before, you could do it by "drawing" each line segment of the box plot using JSL and defining the pen color for each segment. Alternatively, I suppose you could add a JSL script to the graph builder that adds a line at a certain point and then give it a color.
For example, again using the Air.jmp sample data table, you could right click the graph builder (assuming that's what you're using to make the box plot), select Customize, and then click the + symbol to add a script to the data table.
Make sure the location of the Script entity in the list box is at the top so it draws the line above the other elements in the graph. Add a script like the following:
Pen Color( "red" );
Pen Size( 4 );
Pen Color( "red" );
Line({0.75,2.04},{1.24,2.04});
To get:
Notice the thick red line at the mean of the first box plot. You can find the start/end points of the line segments by clicking on the + symbol in the toolbar above the graph:
And wherever you left click in the graph, it will pop up with the coordinates. You can then use those in the Line() script as Line({x1,x1},{x2,y2}). There are other ways to assign the points of the line. See for example, JMP help here.
Hope this helps!,
DS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Change color any line of boxplot
Hi @thiennguyen ,
I'm not sure that it's possible to do that in JMP -- at least to modify the color of any possible line in a box plot.
I played around with the Air.jmp sample data table using :Ozon cencentration and :month as the y and x axes, respectively. You can modify the color of any one box plot and its whiskers, but I don't think you can do that to any one line element of the box plot -- that is unless you build the box plot lines individually and manually create the box plot, which kind of defeats the purpose of using JMP's graphing capabilities.
One of the reasons I think it's not possible is how the box plot is addressed in the JSL version:
Graph Builder(
Graph Spacing( 4 ),
Variables( X( :month ), Y( :Ozone Concentration ) ),
Elements( Box Plot( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{DispatchSeg(
Box Plot Seg( "Box Plot (1)" ),
{Confidence Diamond( 1 ), Shortest Half Bracket( 1 ),
Line Color( "Blue" )}
)}
)
)
);
If you read down the JSL to the Box Plot Seg() command, it is accessing the entire "Box Plot (1)" element as a whole, not an individual line segment. I also checked the tree structure of the graph builder, and it looks like it treats the box plot elements as an entire entity.
Based on this, I don't see a way at the moment to access a single line segment of a box plot and make it a unique color. Sorry it's not a real solution to your question.
Hope this helps,
DS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Change color any line of boxplot
Could you suggest me some key points for solving the problem? Such as I do it in SPSS, R or Python?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Change color any line of boxplot
Hi @thiennguyen ,
Sorry, can't help much there. I'm not familiar with how to do it in SPSS, R or Python. As I mentioned before, you could do it by "drawing" each line segment of the box plot using JSL and defining the pen color for each segment. Alternatively, I suppose you could add a JSL script to the graph builder that adds a line at a certain point and then give it a color.
For example, again using the Air.jmp sample data table, you could right click the graph builder (assuming that's what you're using to make the box plot), select Customize, and then click the + symbol to add a script to the data table.
Make sure the location of the Script entity in the list box is at the top so it draws the line above the other elements in the graph. Add a script like the following:
Pen Color( "red" );
Pen Size( 4 );
Pen Color( "red" );
Line({0.75,2.04},{1.24,2.04});
To get:
Notice the thick red line at the mean of the first box plot. You can find the start/end points of the line segments by clicking on the + symbol in the toolbar above the graph:
And wherever you left click in the graph, it will pop up with the coordinates. You can then use those in the Line() script as Line({x1,x1},{x2,y2}). There are other ways to assign the points of the line. See for example, JMP help here.
Hope this helps!,
DS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Change color any line of boxplot
Hi @thiennguyen, apologies that my reply isn't the answer to the specific question you asked. However, I'm curious about the intent behind the goal of changing the appearance of the line in the boxplot. I wonder if some alternative ideas could address your needs. For example, if the intent is to draw attention to the median-differences in the variables, perhaps adding reference lines in the Y-axis could help? You could do this by:
1) Temporarily adding a caption box to the graph with the median for each variable (so it's visible to use in step 2)
2) Right-clicking on the Y-axis and going into "Axis Settings..."
3) Using the "Reference Lines" options to add a line at the median value and select its color and style
Another idea is to customize a hover label for the lines in the box plots. You can do this by:
1) Hovering over the median line of a box plot and pinning the default popup
2) Right-click on the pinned box and click "Replace Text..."
3) Type whatever information you want to highlight, such as the value of the median, click OK and move the box to any position of your liking
HTH,
~Laura
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Change color any line of boxplot
I'm a new user of JMP, and I previously had experience with SPSS. I find JMP quite appealing, so I've switched to using it instead of SPSS. One feature I really like from SPSS is its user-friendly data visualization platform, which makes graph adjustments easy. While JMP doesn't offer that feature, I understand that no tool is perfect, and I'll continue to use SPSS when JMP can't fulfill my specific needs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Change color any line of boxplot
Most of the lines can be be drawn over using for example Bar Chart with Float style but you might have to add separate calculations for some of them and it can get quite annoying to modify the different variables for different plots