- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How to get heatmap with catergorical coloring
Hello,
I am creating heatmaps with coloring by a numerical values. But I am not able to color by discrete string values.
In the attached datatable, I try to ceate a heatmap colred by different devices: I expected to see a map with a specific color for each Device. But I get a gradient coloring.
How can I change this to get a speific discrete colr for eache device ?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to get heatmap with catergorical coloring
Hi @samir
Although heatmaps can make use of a categorical color variable, as you noticed it does so in a sometimes undesirable way, which is to consider the levels of the color variable as numeric and provide a gradient. This *is* useful at times which those levels can be presumed to have some dimensionality, and you have lots of observations overlapping, since you can then make out the general distribution of your semi-quantitative categorical variable in 2-dimensional space (and since the heatmap is operating on the values of those overlapping points, some numeracy to the color variable is necessary so an average can be computed).
In this case, I might opt for a scatterplot and change the points to squares, and increase the marker size. This yields the following. Is that helpful? (your data table and new script is attached)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to get heatmap with catergorical coloring
One way to get what you want, is to generate the wafermap using JMP graphics.
Here is the simple JSL that does that
Names Default To Here( 1 );
dt = Current Data Table();
xrange = Col Max( :x ) - Col Min( :x );
yrange = Col Max( :y ) - Col Min( :y );
If(
xrange < yrange,
xsize = 1;
ysize = yrange / xrange;,
ysize = 1, xsize = xrange / yrange
);
Summarize( dt, devicesList = By( :Device ) );
colorList = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
xMatrix = [0, 0, 0, 0];
yMatrix = [0, 0, 0, 0];
New Window( "Wafer Map",
Graph Box(
Y Scale( Col Min( :Y ), ySize * Col Max( :Y ) ),
X Scale( Col Min( :X ), xSize * Col Max( :X ) ),
For( i = 1, i <= N Rows( dt ), i++,
xMatrix[1] = xSize * :X[i];
yMatrix[1] = ySize * :Y[i];
xMatrix[2] = xMatrix[1];
yMatrix[2] = YMatrix[1] + ySize;
xMatrix[3] = xMatrix[1] + xSize;
yMatrix[3] = YMatrix[1] + ySize;
xMatrix[4] = xMatrix[1] + xSize;
yMatrix[4] = YMatrix[1];
color = colorList[Loc( devicesList, :Device[i] )[1]];
Fill Color( color );
Polygon( xMatrix, yMatrix );
)
)
)
;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to get heatmap with catergorical coloring
Hi @samir
Although heatmaps can make use of a categorical color variable, as you noticed it does so in a sometimes undesirable way, which is to consider the levels of the color variable as numeric and provide a gradient. This *is* useful at times which those levels can be presumed to have some dimensionality, and you have lots of observations overlapping, since you can then make out the general distribution of your semi-quantitative categorical variable in 2-dimensional space (and since the heatmap is operating on the values of those overlapping points, some numeracy to the color variable is necessary so an average can be computed).
In this case, I might opt for a scatterplot and change the points to squares, and increase the marker size. This yields the following. Is that helpful? (your data table and new script is attached)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to get heatmap with catergorical coloring
Hi @julian ,
First of all, I am disapointed to see that this is a REAL limitation in JMP.
You work around is a step forward, but I cannot use this implementation: It is difficult with the scatter plot to control the size of the points (squares) and lik you showed there are spaces between the squares that give the impression there are empty devices between the colored ones,...
All in all I need to find another way :(
Thanks for the tip.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to get heatmap with catergorical coloring
One way to get what you want, is to generate the wafermap using JMP graphics.
Here is the simple JSL that does that
Names Default To Here( 1 );
dt = Current Data Table();
xrange = Col Max( :x ) - Col Min( :x );
yrange = Col Max( :y ) - Col Min( :y );
If(
xrange < yrange,
xsize = 1;
ysize = yrange / xrange;,
ysize = 1, xsize = xrange / yrange
);
Summarize( dt, devicesList = By( :Device ) );
colorList = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
xMatrix = [0, 0, 0, 0];
yMatrix = [0, 0, 0, 0];
New Window( "Wafer Map",
Graph Box(
Y Scale( Col Min( :Y ), ySize * Col Max( :Y ) ),
X Scale( Col Min( :X ), xSize * Col Max( :X ) ),
For( i = 1, i <= N Rows( dt ), i++,
xMatrix[1] = xSize * :X[i];
yMatrix[1] = ySize * :Y[i];
xMatrix[2] = xMatrix[1];
yMatrix[2] = YMatrix[1] + ySize;
xMatrix[3] = xMatrix[1] + xSize;
yMatrix[3] = YMatrix[1] + ySize;
xMatrix[4] = xMatrix[1] + xSize;
yMatrix[4] = YMatrix[1];
color = colorList[Loc( devicesList, :Device[i] )[1]];
Fill Color( color );
Polygon( xMatrix, yMatrix );
)
)
)
;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to get heatmap with catergorical coloring
Hi @samir,
I certainly understand the frustration! I want you to know the developers who work on Graph Builder understand this frustration, as well. Just to review, JMP 14 (and earlier) generates a quantitative scale for the values of your categorical variable and uses the map of those colors (and averages of those colors) when populating the cells of the heatmap. JMP 15 (coming September 2019) will behave differently: nominal and ordinal variables used in the color role of a heatmap will be treated categorically, with individual color control for each level of the categorical variable. When there are multiple values occupying any cell of the heat map, and those rows have different levels of that categorical variable, the cell color will reflect the average of the designated colors.
Here's a side-by-side of 14 (and earlier), and sneak-peak of the behavior in 15:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to get heatmap with catergorical coloring
That is exactly what I was looking for !!!!!!
I guess I will have to wait till September 2019 :(
I will use the work arounds in the meantime
Thank you all.