cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
Steven_Moore
Level VI

Fit Y by X, is it possible to color the boxes in a Box Plot by a column? What about Graph Builder?

In the Fit Y by x Platform, is it possible to color the boxes by a cloumn?  For example, I have a plot of machine efficiencies (y-axis) against the month/year (x-axis) and would like to have different colors for the boxes by year;  2011 - red, 2012 - blue, etc  I have tried several things, but cannot get the colors.

Steve
1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Box Plots - Color

If you don't need other features of Fit Y by X than box plots, you could try Graph Builder where box plots can be colored by a variable dragged to the Overlay Role.

Try the example code below. (The code demonstrates PMroz tip about the date format, but in my localization "m/y" has to be typed like "m-y".)

dt = New Table("example",

    add rows(360),

    New Column("date",

        Numeric,

        Format("m-y", 7),

        formula(Date Increment(Informat("1-2009", "m-y"), "month", Mod(Row() - 1, 36)))

    ),

    New Column("data", numeric, formula(Random Uniform())),

    New Column("year", nominal, formula(Year(:date)))

);

dt << Graph Builder(Variables(X(:date), Y(:data), Overlay(:year)), Elements(Box Plot(X, Y, Legend(7))));



View solution in original post

4 REPLIES 4
louv
Staff (Retired)

Re: Box Plots - Color

8852_Screen Shot 2015-06-02 at 4.44.24 PM.png

Not sure if this is what you meant but I just right clicked and customized the graph to color the box plot.

Steven_Moore
Level VI

Re: Box Plots - Color

That does not seem to be working for me at all.  Besides, I have 72 boxes (12 months by 6 years).  Seems to me I should be able to color the boxes by year.  Another issue I am having.  I can't find the right format for my "Month" column to make the chart plot the months by time order instead of alphabetical order.  I am getting Apr-01, Apr-02, Apr-03, etc. instead of Jan-01, Feb-01, Mar-01, etc.  I know I can use the value order function in column prop[erties, but what a tedious task!  Any suggestions?

Steve
pmroz
Super User

Re: Box Plots - Color

Two suggestions:

1. Use a format that will sort alphabetically, such as 2015-01, 2015-02, 2015-03 etc.

2. Convert your month column to a numeric, and set the format to "m/y".

Can you give us a flavor of what your data looks like? 

ms
Super User (Alumni) ms
Super User (Alumni)

Re: Box Plots - Color

If you don't need other features of Fit Y by X than box plots, you could try Graph Builder where box plots can be colored by a variable dragged to the Overlay Role.

Try the example code below. (The code demonstrates PMroz tip about the date format, but in my localization "m/y" has to be typed like "m-y".)

dt = New Table("example",

    add rows(360),

    New Column("date",

        Numeric,

        Format("m-y", 7),

        formula(Date Increment(Informat("1-2009", "m-y"), "month", Mod(Row() - 1, 36)))

    ),

    New Column("data", numeric, formula(Random Uniform())),

    New Column("year", nominal, formula(Year(:date)))

);

dt << Graph Builder(Variables(X(:date), Y(:data), Overlay(:year)), Elements(Box Plot(X, Y, Legend(7))));