cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Jrhorowitz4
Level II

Bars not centered on axis labels

I am very new to JMP and it took me almost three hours to make the graph that's in the image attached. I have no idea how to code, but was told to try JMP out for data analysis. My issue right now is that my bars aren't centered on the axis labels. I've tried changing the spacing on the axis, but that just makes the bars move even more. Any help would be appreciated because I am very lost and I have a ton of graphs to still make. If there's also a way to make the bars wider, that'd be great too. I tried the width proportion, but the bars seemed to have doubled so I wasn't sure if that was right. I'm using JMP Pro 14.2. Thank you!

 

JMP Graph Builder.png

7 REPLIES 7
txnelson
Super User

Re: Bars not centered on axis labels

Here is my "solution" to your issue; 

txnelson_1-1680664714818.png

 

I had to make up my own data, and in it, I only had one data point for each bar, so the box plots are not displayed correctly, but I believe with your data, the box plots will work correctly.

My solution, is an ugly solution.  The only redeeming quality to it, is that it displays the data the way you want it to.

Here are the changes that I did to your chart to make it work

  1. I moved Treatment from Overlay to Color.  Overlay forces all Volume levels to be in each overlay, thus your offset labels.
  2. Rather than just having Volume as your X axis, I included both  Volume and Treatment on the axis.
    1. To remove the axis values for Treatment, I went into the Axis Settings for Treatment and unselected "Show Tick Labels"
    2. To change the Axis Label that is listing both Volume and Treatment, I clicked on the label and typed in Volume
  3. I then Right Clicked on the graph, and selected Customize
    1. I selected Bar, and changed the Width Proportion to 1
  4. Now to add the spacing between the Volume groups I added dummy records in the data table.
    1. For each level of Volume( 100, 150....Ethanol) I added 2 dummy records
    2. The values for the Treatment for the dummy records have one value that will be displayed before the current treatment levels and one that will appear after.  I chose the values of A-spacer and Z-Spacer.  Here is the data table with the dummy row                                                                                         txnelson_2-1680666399529.png

       

  5. I then right clicked above the Legend, and selected Legend Settings
    1. In here I selected only the categories I wanted to be displayed.

I call this pretty ugly, and I hope that another Community member will have a better solution.  Here is the JSL that will reproduce my graph, as long as you have the dummy records added.

Names Default to Here( 1 );

Graph Builder(
	Size( 570, 488 ),
	Graph Spacing( 0 ),
	Variables(
		X( :Volume ),
		X( :Treatment, Position( 1 ) ),
		Y( :RLU ),
		Color( :Treatment )
	),
	Elements(
		Bar( X( 1 ), X( 2 ), Y, Legend( 6 ), Packed Primaries( 5 ) ),
		Box Plot( X( 1 ), X( 2 ), Y, Legend( 7 ) )
	),
	SendToReport(
		Dispatch(
			{},
			"Volume",
			ScaleBox,
			{Label Row(
				1,
				{Automatic Tick Marks( 0 ), Show Major Labels( 0 ),
				Tick Mark Style( "Short Divider" )}
			), Label Row( 2, Tick Mark Style( "Short Divider" ) )}
		),
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				6,
				Properties( 1, {Fill Color( 52 )}, Item ID( "Cell-Treated", 1 ) ),
				Properties(
					2,
					{Fill Color( 21 )},
					Item ID( "Negative-Control", 1 )
				),
				Properties(
					3,
					{Fill Color( 51 )},
					Item ID( "Positive-Control", 1 )
				),
				Properties( 4, {Fill Color( 56 )}, Item ID( "Virus-Treated", 1 ) ),
				Properties( -1, {Fill Color( 52 )}, Item ID( "RLU", 1 ) )
			), Legend Model( 7, Base( 7, 0, 0, Item ID( "RLU", 2 ) ) )}
		),
		Dispatch( {}, "X title", TextEditBox, {Set Text( "Volume" )} ),
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{DispatchSeg( BarSeg( 1 ), {Set Width Proportion( 1 )} )}
		),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position(
				{6, [-1, 2, 0, 1, 3, -1], 7, [-1, -1, -1, -1, -1, -1, -1, -1]}
			)}
		)
	)
)
Jim
Jrhorowitz4
Level II

Re: Bars not centered on axis labels

Thank you so much for answering! I saw where to put the script yesterday, but now I'm having trouble finding it so I worked through your steps. Everything was working great until I got to the spacers part. Both the A-spacer and Z-spacer were showing up at the end of the bar, instead of one at the beginning and one at the end, so it shifted the bar over two spaces. I tried to put them in with my data instead of at the end, or just adding one spacer, but I haven't found a way to make it work like you did yet. When I went to rearrange the order of the treatments to put the spacers first, they weren't showing up as labels to move in the box.

Re: Bars not centered on axis labels

I think this plot is correct, though you find it undesirable. You seem to be missing some combinations of Treatment and Volume, but JMP still leaves the position, so the omission is clear.

Jrhorowitz4
Level II

Re: Bars not centered on axis labels

Oh I see. I'm not sure what combination would be missing but I'll take a look at it. Thank you for replying!

Jeff_Perkinson
Community Manager Community Manager

Re: Bars not centered on axis labels

You've put Treatment in the Overlay role so you've asked for one bar for each Treatment/Volume combination. However, you only have A549/Negative Control in your data (for example). 

 

It might help to get a sense of what graph you'd like to see, and how your data is organized.

-Jeff
Jrhorowitz4
Level II

Re: Bars not centered on axis labels

Wow, that issue just clicked for me. Sorry it took so long! I'm guessing there's no way to override that then, since the Negative and Positive Controls only have one type of variable, but the Cell Treated and Virus Treated have four. I essentially want what txnelson posted an image of in the first reply, that would be perfect. I just wasn't able to mimic what they did with their data. I included a portion of my data table that I was basing my graph on just in case. The label column was my way of cheating to identify the statistically different values. Thank you for the help! 

 

Screenshot 2023-04-05 122236.png

txnelson
Super User

Re: Bars not centered on axis labels

If you can attach a copy of your data table, I will take a look at it and see if I can get it to work using the funky method I used.

Jim