Building a nine - region cluster chart with Tooltip to display labels associated with 2D pointsQuestion about BorderingCountiesListPlot with labels that appear when the pointer goes over the pointsHow do I display the numeric value of a curve with Tooltip?Annotating plots by adding labels with arrows connecting them to data points

Is it really necessary to have a four hour meeting in Sprint planning?

Going to France with limited French for a day

Why does (inf + 0j)*1 evaluate to inf + nanj?

Why does NASA publish all the results/data it gets?

A food item only made possible by time-freezing storage?

Safe to use 220V electric clothes dryer when building has been bridged down to 110V?

Designing a time thief proof safe

What benefits does the Power Word Kill spell have?

Lettrine + string manipulation + some fonts = errors and weird issues

Strange Sticky Substance on Digital Camera

Can you cast Dispel Magic on a Shadow Monk's Silence?

Should the average user with no special access rights be worried about SMS-based 2FA being theoretically interceptable?

Examples of "unsuccessful" theories with afterlives

practicality of 30 year fix mortgage at 55 years of age

Comma Code - Automate the Boring Stuff with Python

Safely hang a mirror that does not have hooks

Does HTTP HSTS protect a domain from a bad-actor publically-trusted-CA issing a illegitimate valid certificate?

A delve into extraordinary chess problems: Selfmate 1

What is the meaning of word 'crack' in chapter 33 of A Game of Thrones?

Is it a good idea to leave minor world details to the reader's imagination?

Meaning of 'ran' in German?

word frequency from file using partial match

How to conceptualize Newton's apple?

My manager quit. Should I agree to defer wage increase to accommodate budget concerns?



Building a nine - region cluster chart with Tooltip to display labels associated with 2D points


Question about BorderingCountiesListPlot with labels that appear when the pointer goes over the pointsHow do I display the numeric value of a curve with Tooltip?Annotating plots by adding labels with arrows connecting them to data points






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3












$begingroup$


I'm attempting to build a nine-region cluster chart using Tooltip to display labels associated with 2-D points also displayed on it. I do NOT want to use "FindClusters". I want to design my own cluster chart as explained below. The following mock data is made-up of 2-D points where each points have a label-identifier called a "NAICS" code (NAICS stands for "North American Industry
Classification System").



mockdataWithNAICS = "29-1141", 186, 112, "41-2031", 123, 92, "41-1011", 65, 404, "43-4051", 108, 646, "31-1014", 643, 246,
"49-9071", 356, 363, "43-1011", 543, 381, "43-5081", 268, 674, "53-3032", 416, 653, "37-3011", 514, 428, "37-2012", 501, 58,
"33-9032", 441, 598, "35-2014", 633, 138, "29-2061", 414, 590, "53-3033", 98, 155, "35-3031", 179, 431, "49-3023", 93, 623,
"35-3021", 37, 578, "41-2011", 256, 237, "37-2011", 302, 50, "47-1011", 518, 2, "11-9111", 313, 294, "31-9092", 698, 136,
"43-3031", 608, 610, "43-6013", 562, 515, "13-2011", 415, 327, "21-1093", 191, 72, "41-4012", 212, 92, "41-3031", 546, 418,
"31-1011", 591, 49, "47-2031", 405, 526, "41-3021", 191, 297, "15-1151", 442, 445, "43-6011", 118, 185, "49-1011", 472, 402,
"53-7062", 348, 552, "43-4171", 409, 396, "43-6014", 348, 247, "53-1031", 629, 59, "47-2061", 589, 534, "27-1026", 22, 377,
"29-1069", 445, 74, "49-9021", 647, 539, "43-9061", 25, 543, "11-1021", 19, 165, "41-1012", 482, 199, "29-1062", 1, 68,
"43-4081", 217, 112, "41-3099", 663, 66, "11-3031", 329, 392, "53-7061", 357, 515, "35-2021", 488, 245, "31-9091", 318, 679,
"51-1011", 650, 349, "11-9051", 38, 145, "53-3031", 166, 691, "39-9021", 561, 127, "39-5012", 665, 362, "47-2111", 397, 532,
"43-3071", 326, 271, "29-2034", 361, 450, "35-9011", 12, 366, "29-1123", 16, 211, "15-1142",162, 662, "11-2021", 520, 164,
"29-2031", 339, 619, "25-2011", 263, 564, "41-4011", 551, 301, "29-2055", 76, 549, "29-2052", 285, 640, "13-2072", 370, 542,
"35-2012", 512, 547, "11-2022", 130, 154, "15-1132", 188, 274, "13-2052", 338, 587, "15-1199", 455, 5, "35-9031", 595, 472,
"17-2051", 648, 481, "11-9199", 430, 189, "39-3091", 29, 396, "47-2152", 412, 342, "29-1122", 582, 20, "11-9141", 276, 4,
"25-2021", 666, 617, "15-1134", 236, 334, "37-1011", 407, 664, "29-1063", 260, 278, "49-3031", 161, 354, "41-9022", 185, 144,
"41-9041", 551, 628, "25-2031", 529, 505, "29-2071", 548, 296, "29-1127", 373, 124, "21-1023", 473, 71, "29-1067", 489, 569,
"29-1071", 539, 277, "11-3121", 390, 348, "11-9021", 634, 20, "53-3041", 589, 258, "49-3021", 47, 206;

L = Length[mockdataWithNAICS];
counter = Range[L];
counter = Range[L];
mock2Dvalues = mockdataWithNAICS[[#]][[2]], mockdataWithNAICS[[#]][[3]] & /@ counter


The following measurements are necessary to build a grid :



minx = Round[Min[Table[mock2Dvalues[[i]][[1]], i, 1, L]]];
maxx = Round[Max[Table[mock2Dvalues[[i]][[1]], i, 1, L]]];

dx = Round[Subdivide[minx, maxx, 3]];

miny = Round[Min[Table[mock2Dvalues[[i]][[2]], i, 1, L]]];

maxy = Round[Max[Table[mock2Dvalues[[i]][[2]], i, 1, L]]];

dy = Round[Subdivide[miny, maxy, 3]];

gridpts = Tuples[dx, dy];


The following plot will allow you to visualize the grid and all the data points :



plt1 = ListPlot[gridpts, Frame -> True, PlotStyle -> Black, 
GridLines -> dx, dy, Epilog :> Blue, Point[mock2Dvalues]]


Mathematica graphics



The purpose of the following plot is to allow you to display the grid
points with the aid of Tooltip to define the following nine regions :



plt2 = ListPlot[Tooltip[gridpts], Frame -> True, PlotStyle -> Black, 
GridLines -> dx, dy]


Mathematica graphics



Here we define the nine cluster regions. We assign colors to the region names as a "mnemonic device" to associate the 2-D points with the regions that they belong-to, according to color. The colors are arbitrary :



 magentaregion = Rectangle[gridpts[[1]], gridpts[[6]]]

orangeregion = Rectangle[gridpts[[5]], gridpts[[10]]]

cyanregion = Rectangle[gridpts[[9]], gridpts[[14]]]

redregion = Rectangle[gridpts[[2]], gridpts[[7]]]

blueregion = Rectangle[gridpts[[6]], gridpts[[11]]]

greenregion = Rectangle[gridpts[[10]], gridpts[[15]]]

lightgrayregion = Rectangle[gridpts[[3]], gridpts[[8]]]

yellowregion = Rectangle[gridpts[[7]], gridpts[[12]]]

blackregion = Rectangle[gridpts[[11]], gridpts[[16]]]


Here we disburse the points according to the regions where they belong to :



magentapts = Select[mock2Dvalues, # [Element] magentaregion &]

orangepts = Select[mock2Dvalues, # [Element] orangeregion &]

cyanpts = Select[mock2Dvalues, # [Element] cyanregion &]

redpts = Select[mock2Dvalues, # [Element] redregion &]

bluepts = Select[mock2Dvalues, # [Element] blueregion &]

greenpts = Select[mock2Dvalues, # [Element] greenregion &]

lightgraypts = Select[mock2Dvalues, # [Element] lightgrayregion &]

yellowpts = Select[mock2Dvalues, # [Element] yellowregion &]

blackpts = Select[mock2Dvalues, # [Element] blackregion &]


The following plots are necessary to build the final chart below :



plt3 = ListPlot[magentapts, Frame -> True, PlotStyle -> Magenta, 
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt4 = ListPlot[orangepts, Frame -> True, PlotStyle -> Orange,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt5 = ListPlot[cyanpts, Frame -> True, PlotStyle -> Cyan,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt6 = ListPlot[redpts, Frame -> True, PlotStyle -> Red,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt7 = ListPlot[bluepts, Frame -> True, PlotStyle -> Blue,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt8 = ListPlot[greenpts, Frame -> True, PlotStyle -> Green,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt9 = ListPlot[lightgraypts, Frame -> True, PlotStyle -> LightGray,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt10 = ListPlot[yellowpts, Frame -> True, PlotStyle -> Yellow,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt11 = ListPlot[blackpts, Frame -> True, PlotStyle -> Black,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];


This plot shows the nine-region cluster chart with the points colored by the region that they belong to :



finalchart = Show[plt3, plt4, plt5, plt6, plt7, plt8, plt9, plt10, plt11]


Mathematica graphics



Finally; we establish an association between the NAICS codes and their 2 - D points as follows:



mockdataWithNAICSlabels = 
Association[#[[1]] -> #[[2 ;; 3]] & /@ mockdataWithNAICS];

Dataset[mockdataWithNAICSlabels]


My question is: How can I associate the NAICS codes to their respective points BY COLORED REGION, so that if I use Tooltip; the NAICS codes will be displayed for each point in the above finalchart? Thank you!










share|improve this question











$endgroup$













  • $begingroup$
    Gilmar, a gentle reminder (if I may) re the comments following this post of yours re your previous questions
    $endgroup$
    – kglr
    10 hours ago










  • $begingroup$
    Dear Carl @kglr: I read your answer at the time and accepted your answer. I'm not sure what you are trying to tell me? That was a different topic (and post) altogether. Please, elaborate if you must.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago










  • $begingroup$
    @kglr How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago











  • $begingroup$
    @Carl Lange How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago











  • $begingroup$
    Thank you Gilmar. This is strange; you should be able accept/unaccept anytime. Perhaps this calls for developer/moderator attention to fix whatever is wrong with the pages you are seeing.
    $endgroup$
    – kglr
    8 hours ago

















3












$begingroup$


I'm attempting to build a nine-region cluster chart using Tooltip to display labels associated with 2-D points also displayed on it. I do NOT want to use "FindClusters". I want to design my own cluster chart as explained below. The following mock data is made-up of 2-D points where each points have a label-identifier called a "NAICS" code (NAICS stands for "North American Industry
Classification System").



mockdataWithNAICS = "29-1141", 186, 112, "41-2031", 123, 92, "41-1011", 65, 404, "43-4051", 108, 646, "31-1014", 643, 246,
"49-9071", 356, 363, "43-1011", 543, 381, "43-5081", 268, 674, "53-3032", 416, 653, "37-3011", 514, 428, "37-2012", 501, 58,
"33-9032", 441, 598, "35-2014", 633, 138, "29-2061", 414, 590, "53-3033", 98, 155, "35-3031", 179, 431, "49-3023", 93, 623,
"35-3021", 37, 578, "41-2011", 256, 237, "37-2011", 302, 50, "47-1011", 518, 2, "11-9111", 313, 294, "31-9092", 698, 136,
"43-3031", 608, 610, "43-6013", 562, 515, "13-2011", 415, 327, "21-1093", 191, 72, "41-4012", 212, 92, "41-3031", 546, 418,
"31-1011", 591, 49, "47-2031", 405, 526, "41-3021", 191, 297, "15-1151", 442, 445, "43-6011", 118, 185, "49-1011", 472, 402,
"53-7062", 348, 552, "43-4171", 409, 396, "43-6014", 348, 247, "53-1031", 629, 59, "47-2061", 589, 534, "27-1026", 22, 377,
"29-1069", 445, 74, "49-9021", 647, 539, "43-9061", 25, 543, "11-1021", 19, 165, "41-1012", 482, 199, "29-1062", 1, 68,
"43-4081", 217, 112, "41-3099", 663, 66, "11-3031", 329, 392, "53-7061", 357, 515, "35-2021", 488, 245, "31-9091", 318, 679,
"51-1011", 650, 349, "11-9051", 38, 145, "53-3031", 166, 691, "39-9021", 561, 127, "39-5012", 665, 362, "47-2111", 397, 532,
"43-3071", 326, 271, "29-2034", 361, 450, "35-9011", 12, 366, "29-1123", 16, 211, "15-1142",162, 662, "11-2021", 520, 164,
"29-2031", 339, 619, "25-2011", 263, 564, "41-4011", 551, 301, "29-2055", 76, 549, "29-2052", 285, 640, "13-2072", 370, 542,
"35-2012", 512, 547, "11-2022", 130, 154, "15-1132", 188, 274, "13-2052", 338, 587, "15-1199", 455, 5, "35-9031", 595, 472,
"17-2051", 648, 481, "11-9199", 430, 189, "39-3091", 29, 396, "47-2152", 412, 342, "29-1122", 582, 20, "11-9141", 276, 4,
"25-2021", 666, 617, "15-1134", 236, 334, "37-1011", 407, 664, "29-1063", 260, 278, "49-3031", 161, 354, "41-9022", 185, 144,
"41-9041", 551, 628, "25-2031", 529, 505, "29-2071", 548, 296, "29-1127", 373, 124, "21-1023", 473, 71, "29-1067", 489, 569,
"29-1071", 539, 277, "11-3121", 390, 348, "11-9021", 634, 20, "53-3041", 589, 258, "49-3021", 47, 206;

L = Length[mockdataWithNAICS];
counter = Range[L];
counter = Range[L];
mock2Dvalues = mockdataWithNAICS[[#]][[2]], mockdataWithNAICS[[#]][[3]] & /@ counter


The following measurements are necessary to build a grid :



minx = Round[Min[Table[mock2Dvalues[[i]][[1]], i, 1, L]]];
maxx = Round[Max[Table[mock2Dvalues[[i]][[1]], i, 1, L]]];

dx = Round[Subdivide[minx, maxx, 3]];

miny = Round[Min[Table[mock2Dvalues[[i]][[2]], i, 1, L]]];

maxy = Round[Max[Table[mock2Dvalues[[i]][[2]], i, 1, L]]];

dy = Round[Subdivide[miny, maxy, 3]];

gridpts = Tuples[dx, dy];


The following plot will allow you to visualize the grid and all the data points :



plt1 = ListPlot[gridpts, Frame -> True, PlotStyle -> Black, 
GridLines -> dx, dy, Epilog :> Blue, Point[mock2Dvalues]]


Mathematica graphics



The purpose of the following plot is to allow you to display the grid
points with the aid of Tooltip to define the following nine regions :



plt2 = ListPlot[Tooltip[gridpts], Frame -> True, PlotStyle -> Black, 
GridLines -> dx, dy]


Mathematica graphics



Here we define the nine cluster regions. We assign colors to the region names as a "mnemonic device" to associate the 2-D points with the regions that they belong-to, according to color. The colors are arbitrary :



 magentaregion = Rectangle[gridpts[[1]], gridpts[[6]]]

orangeregion = Rectangle[gridpts[[5]], gridpts[[10]]]

cyanregion = Rectangle[gridpts[[9]], gridpts[[14]]]

redregion = Rectangle[gridpts[[2]], gridpts[[7]]]

blueregion = Rectangle[gridpts[[6]], gridpts[[11]]]

greenregion = Rectangle[gridpts[[10]], gridpts[[15]]]

lightgrayregion = Rectangle[gridpts[[3]], gridpts[[8]]]

yellowregion = Rectangle[gridpts[[7]], gridpts[[12]]]

blackregion = Rectangle[gridpts[[11]], gridpts[[16]]]


Here we disburse the points according to the regions where they belong to :



magentapts = Select[mock2Dvalues, # [Element] magentaregion &]

orangepts = Select[mock2Dvalues, # [Element] orangeregion &]

cyanpts = Select[mock2Dvalues, # [Element] cyanregion &]

redpts = Select[mock2Dvalues, # [Element] redregion &]

bluepts = Select[mock2Dvalues, # [Element] blueregion &]

greenpts = Select[mock2Dvalues, # [Element] greenregion &]

lightgraypts = Select[mock2Dvalues, # [Element] lightgrayregion &]

yellowpts = Select[mock2Dvalues, # [Element] yellowregion &]

blackpts = Select[mock2Dvalues, # [Element] blackregion &]


The following plots are necessary to build the final chart below :



plt3 = ListPlot[magentapts, Frame -> True, PlotStyle -> Magenta, 
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt4 = ListPlot[orangepts, Frame -> True, PlotStyle -> Orange,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt5 = ListPlot[cyanpts, Frame -> True, PlotStyle -> Cyan,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt6 = ListPlot[redpts, Frame -> True, PlotStyle -> Red,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt7 = ListPlot[bluepts, Frame -> True, PlotStyle -> Blue,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt8 = ListPlot[greenpts, Frame -> True, PlotStyle -> Green,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt9 = ListPlot[lightgraypts, Frame -> True, PlotStyle -> LightGray,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt10 = ListPlot[yellowpts, Frame -> True, PlotStyle -> Yellow,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt11 = ListPlot[blackpts, Frame -> True, PlotStyle -> Black,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];


This plot shows the nine-region cluster chart with the points colored by the region that they belong to :



finalchart = Show[plt3, plt4, plt5, plt6, plt7, plt8, plt9, plt10, plt11]


Mathematica graphics



Finally; we establish an association between the NAICS codes and their 2 - D points as follows:



mockdataWithNAICSlabels = 
Association[#[[1]] -> #[[2 ;; 3]] & /@ mockdataWithNAICS];

Dataset[mockdataWithNAICSlabels]


My question is: How can I associate the NAICS codes to their respective points BY COLORED REGION, so that if I use Tooltip; the NAICS codes will be displayed for each point in the above finalchart? Thank you!










share|improve this question











$endgroup$













  • $begingroup$
    Gilmar, a gentle reminder (if I may) re the comments following this post of yours re your previous questions
    $endgroup$
    – kglr
    10 hours ago










  • $begingroup$
    Dear Carl @kglr: I read your answer at the time and accepted your answer. I'm not sure what you are trying to tell me? That was a different topic (and post) altogether. Please, elaborate if you must.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago










  • $begingroup$
    @kglr How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago











  • $begingroup$
    @Carl Lange How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago











  • $begingroup$
    Thank you Gilmar. This is strange; you should be able accept/unaccept anytime. Perhaps this calls for developer/moderator attention to fix whatever is wrong with the pages you are seeing.
    $endgroup$
    – kglr
    8 hours ago













3












3








3





$begingroup$


I'm attempting to build a nine-region cluster chart using Tooltip to display labels associated with 2-D points also displayed on it. I do NOT want to use "FindClusters". I want to design my own cluster chart as explained below. The following mock data is made-up of 2-D points where each points have a label-identifier called a "NAICS" code (NAICS stands for "North American Industry
Classification System").



mockdataWithNAICS = "29-1141", 186, 112, "41-2031", 123, 92, "41-1011", 65, 404, "43-4051", 108, 646, "31-1014", 643, 246,
"49-9071", 356, 363, "43-1011", 543, 381, "43-5081", 268, 674, "53-3032", 416, 653, "37-3011", 514, 428, "37-2012", 501, 58,
"33-9032", 441, 598, "35-2014", 633, 138, "29-2061", 414, 590, "53-3033", 98, 155, "35-3031", 179, 431, "49-3023", 93, 623,
"35-3021", 37, 578, "41-2011", 256, 237, "37-2011", 302, 50, "47-1011", 518, 2, "11-9111", 313, 294, "31-9092", 698, 136,
"43-3031", 608, 610, "43-6013", 562, 515, "13-2011", 415, 327, "21-1093", 191, 72, "41-4012", 212, 92, "41-3031", 546, 418,
"31-1011", 591, 49, "47-2031", 405, 526, "41-3021", 191, 297, "15-1151", 442, 445, "43-6011", 118, 185, "49-1011", 472, 402,
"53-7062", 348, 552, "43-4171", 409, 396, "43-6014", 348, 247, "53-1031", 629, 59, "47-2061", 589, 534, "27-1026", 22, 377,
"29-1069", 445, 74, "49-9021", 647, 539, "43-9061", 25, 543, "11-1021", 19, 165, "41-1012", 482, 199, "29-1062", 1, 68,
"43-4081", 217, 112, "41-3099", 663, 66, "11-3031", 329, 392, "53-7061", 357, 515, "35-2021", 488, 245, "31-9091", 318, 679,
"51-1011", 650, 349, "11-9051", 38, 145, "53-3031", 166, 691, "39-9021", 561, 127, "39-5012", 665, 362, "47-2111", 397, 532,
"43-3071", 326, 271, "29-2034", 361, 450, "35-9011", 12, 366, "29-1123", 16, 211, "15-1142",162, 662, "11-2021", 520, 164,
"29-2031", 339, 619, "25-2011", 263, 564, "41-4011", 551, 301, "29-2055", 76, 549, "29-2052", 285, 640, "13-2072", 370, 542,
"35-2012", 512, 547, "11-2022", 130, 154, "15-1132", 188, 274, "13-2052", 338, 587, "15-1199", 455, 5, "35-9031", 595, 472,
"17-2051", 648, 481, "11-9199", 430, 189, "39-3091", 29, 396, "47-2152", 412, 342, "29-1122", 582, 20, "11-9141", 276, 4,
"25-2021", 666, 617, "15-1134", 236, 334, "37-1011", 407, 664, "29-1063", 260, 278, "49-3031", 161, 354, "41-9022", 185, 144,
"41-9041", 551, 628, "25-2031", 529, 505, "29-2071", 548, 296, "29-1127", 373, 124, "21-1023", 473, 71, "29-1067", 489, 569,
"29-1071", 539, 277, "11-3121", 390, 348, "11-9021", 634, 20, "53-3041", 589, 258, "49-3021", 47, 206;

L = Length[mockdataWithNAICS];
counter = Range[L];
counter = Range[L];
mock2Dvalues = mockdataWithNAICS[[#]][[2]], mockdataWithNAICS[[#]][[3]] & /@ counter


The following measurements are necessary to build a grid :



minx = Round[Min[Table[mock2Dvalues[[i]][[1]], i, 1, L]]];
maxx = Round[Max[Table[mock2Dvalues[[i]][[1]], i, 1, L]]];

dx = Round[Subdivide[minx, maxx, 3]];

miny = Round[Min[Table[mock2Dvalues[[i]][[2]], i, 1, L]]];

maxy = Round[Max[Table[mock2Dvalues[[i]][[2]], i, 1, L]]];

dy = Round[Subdivide[miny, maxy, 3]];

gridpts = Tuples[dx, dy];


The following plot will allow you to visualize the grid and all the data points :



plt1 = ListPlot[gridpts, Frame -> True, PlotStyle -> Black, 
GridLines -> dx, dy, Epilog :> Blue, Point[mock2Dvalues]]


Mathematica graphics



The purpose of the following plot is to allow you to display the grid
points with the aid of Tooltip to define the following nine regions :



plt2 = ListPlot[Tooltip[gridpts], Frame -> True, PlotStyle -> Black, 
GridLines -> dx, dy]


Mathematica graphics



Here we define the nine cluster regions. We assign colors to the region names as a "mnemonic device" to associate the 2-D points with the regions that they belong-to, according to color. The colors are arbitrary :



 magentaregion = Rectangle[gridpts[[1]], gridpts[[6]]]

orangeregion = Rectangle[gridpts[[5]], gridpts[[10]]]

cyanregion = Rectangle[gridpts[[9]], gridpts[[14]]]

redregion = Rectangle[gridpts[[2]], gridpts[[7]]]

blueregion = Rectangle[gridpts[[6]], gridpts[[11]]]

greenregion = Rectangle[gridpts[[10]], gridpts[[15]]]

lightgrayregion = Rectangle[gridpts[[3]], gridpts[[8]]]

yellowregion = Rectangle[gridpts[[7]], gridpts[[12]]]

blackregion = Rectangle[gridpts[[11]], gridpts[[16]]]


Here we disburse the points according to the regions where they belong to :



magentapts = Select[mock2Dvalues, # [Element] magentaregion &]

orangepts = Select[mock2Dvalues, # [Element] orangeregion &]

cyanpts = Select[mock2Dvalues, # [Element] cyanregion &]

redpts = Select[mock2Dvalues, # [Element] redregion &]

bluepts = Select[mock2Dvalues, # [Element] blueregion &]

greenpts = Select[mock2Dvalues, # [Element] greenregion &]

lightgraypts = Select[mock2Dvalues, # [Element] lightgrayregion &]

yellowpts = Select[mock2Dvalues, # [Element] yellowregion &]

blackpts = Select[mock2Dvalues, # [Element] blackregion &]


The following plots are necessary to build the final chart below :



plt3 = ListPlot[magentapts, Frame -> True, PlotStyle -> Magenta, 
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt4 = ListPlot[orangepts, Frame -> True, PlotStyle -> Orange,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt5 = ListPlot[cyanpts, Frame -> True, PlotStyle -> Cyan,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt6 = ListPlot[redpts, Frame -> True, PlotStyle -> Red,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt7 = ListPlot[bluepts, Frame -> True, PlotStyle -> Blue,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt8 = ListPlot[greenpts, Frame -> True, PlotStyle -> Green,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt9 = ListPlot[lightgraypts, Frame -> True, PlotStyle -> LightGray,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt10 = ListPlot[yellowpts, Frame -> True, PlotStyle -> Yellow,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt11 = ListPlot[blackpts, Frame -> True, PlotStyle -> Black,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];


This plot shows the nine-region cluster chart with the points colored by the region that they belong to :



finalchart = Show[plt3, plt4, plt5, plt6, plt7, plt8, plt9, plt10, plt11]


Mathematica graphics



Finally; we establish an association between the NAICS codes and their 2 - D points as follows:



mockdataWithNAICSlabels = 
Association[#[[1]] -> #[[2 ;; 3]] & /@ mockdataWithNAICS];

Dataset[mockdataWithNAICSlabels]


My question is: How can I associate the NAICS codes to their respective points BY COLORED REGION, so that if I use Tooltip; the NAICS codes will be displayed for each point in the above finalchart? Thank you!










share|improve this question











$endgroup$




I'm attempting to build a nine-region cluster chart using Tooltip to display labels associated with 2-D points also displayed on it. I do NOT want to use "FindClusters". I want to design my own cluster chart as explained below. The following mock data is made-up of 2-D points where each points have a label-identifier called a "NAICS" code (NAICS stands for "North American Industry
Classification System").



mockdataWithNAICS = "29-1141", 186, 112, "41-2031", 123, 92, "41-1011", 65, 404, "43-4051", 108, 646, "31-1014", 643, 246,
"49-9071", 356, 363, "43-1011", 543, 381, "43-5081", 268, 674, "53-3032", 416, 653, "37-3011", 514, 428, "37-2012", 501, 58,
"33-9032", 441, 598, "35-2014", 633, 138, "29-2061", 414, 590, "53-3033", 98, 155, "35-3031", 179, 431, "49-3023", 93, 623,
"35-3021", 37, 578, "41-2011", 256, 237, "37-2011", 302, 50, "47-1011", 518, 2, "11-9111", 313, 294, "31-9092", 698, 136,
"43-3031", 608, 610, "43-6013", 562, 515, "13-2011", 415, 327, "21-1093", 191, 72, "41-4012", 212, 92, "41-3031", 546, 418,
"31-1011", 591, 49, "47-2031", 405, 526, "41-3021", 191, 297, "15-1151", 442, 445, "43-6011", 118, 185, "49-1011", 472, 402,
"53-7062", 348, 552, "43-4171", 409, 396, "43-6014", 348, 247, "53-1031", 629, 59, "47-2061", 589, 534, "27-1026", 22, 377,
"29-1069", 445, 74, "49-9021", 647, 539, "43-9061", 25, 543, "11-1021", 19, 165, "41-1012", 482, 199, "29-1062", 1, 68,
"43-4081", 217, 112, "41-3099", 663, 66, "11-3031", 329, 392, "53-7061", 357, 515, "35-2021", 488, 245, "31-9091", 318, 679,
"51-1011", 650, 349, "11-9051", 38, 145, "53-3031", 166, 691, "39-9021", 561, 127, "39-5012", 665, 362, "47-2111", 397, 532,
"43-3071", 326, 271, "29-2034", 361, 450, "35-9011", 12, 366, "29-1123", 16, 211, "15-1142",162, 662, "11-2021", 520, 164,
"29-2031", 339, 619, "25-2011", 263, 564, "41-4011", 551, 301, "29-2055", 76, 549, "29-2052", 285, 640, "13-2072", 370, 542,
"35-2012", 512, 547, "11-2022", 130, 154, "15-1132", 188, 274, "13-2052", 338, 587, "15-1199", 455, 5, "35-9031", 595, 472,
"17-2051", 648, 481, "11-9199", 430, 189, "39-3091", 29, 396, "47-2152", 412, 342, "29-1122", 582, 20, "11-9141", 276, 4,
"25-2021", 666, 617, "15-1134", 236, 334, "37-1011", 407, 664, "29-1063", 260, 278, "49-3031", 161, 354, "41-9022", 185, 144,
"41-9041", 551, 628, "25-2031", 529, 505, "29-2071", 548, 296, "29-1127", 373, 124, "21-1023", 473, 71, "29-1067", 489, 569,
"29-1071", 539, 277, "11-3121", 390, 348, "11-9021", 634, 20, "53-3041", 589, 258, "49-3021", 47, 206;

L = Length[mockdataWithNAICS];
counter = Range[L];
counter = Range[L];
mock2Dvalues = mockdataWithNAICS[[#]][[2]], mockdataWithNAICS[[#]][[3]] & /@ counter


The following measurements are necessary to build a grid :



minx = Round[Min[Table[mock2Dvalues[[i]][[1]], i, 1, L]]];
maxx = Round[Max[Table[mock2Dvalues[[i]][[1]], i, 1, L]]];

dx = Round[Subdivide[minx, maxx, 3]];

miny = Round[Min[Table[mock2Dvalues[[i]][[2]], i, 1, L]]];

maxy = Round[Max[Table[mock2Dvalues[[i]][[2]], i, 1, L]]];

dy = Round[Subdivide[miny, maxy, 3]];

gridpts = Tuples[dx, dy];


The following plot will allow you to visualize the grid and all the data points :



plt1 = ListPlot[gridpts, Frame -> True, PlotStyle -> Black, 
GridLines -> dx, dy, Epilog :> Blue, Point[mock2Dvalues]]


Mathematica graphics



The purpose of the following plot is to allow you to display the grid
points with the aid of Tooltip to define the following nine regions :



plt2 = ListPlot[Tooltip[gridpts], Frame -> True, PlotStyle -> Black, 
GridLines -> dx, dy]


Mathematica graphics



Here we define the nine cluster regions. We assign colors to the region names as a "mnemonic device" to associate the 2-D points with the regions that they belong-to, according to color. The colors are arbitrary :



 magentaregion = Rectangle[gridpts[[1]], gridpts[[6]]]

orangeregion = Rectangle[gridpts[[5]], gridpts[[10]]]

cyanregion = Rectangle[gridpts[[9]], gridpts[[14]]]

redregion = Rectangle[gridpts[[2]], gridpts[[7]]]

blueregion = Rectangle[gridpts[[6]], gridpts[[11]]]

greenregion = Rectangle[gridpts[[10]], gridpts[[15]]]

lightgrayregion = Rectangle[gridpts[[3]], gridpts[[8]]]

yellowregion = Rectangle[gridpts[[7]], gridpts[[12]]]

blackregion = Rectangle[gridpts[[11]], gridpts[[16]]]


Here we disburse the points according to the regions where they belong to :



magentapts = Select[mock2Dvalues, # [Element] magentaregion &]

orangepts = Select[mock2Dvalues, # [Element] orangeregion &]

cyanpts = Select[mock2Dvalues, # [Element] cyanregion &]

redpts = Select[mock2Dvalues, # [Element] redregion &]

bluepts = Select[mock2Dvalues, # [Element] blueregion &]

greenpts = Select[mock2Dvalues, # [Element] greenregion &]

lightgraypts = Select[mock2Dvalues, # [Element] lightgrayregion &]

yellowpts = Select[mock2Dvalues, # [Element] yellowregion &]

blackpts = Select[mock2Dvalues, # [Element] blackregion &]


The following plots are necessary to build the final chart below :



plt3 = ListPlot[magentapts, Frame -> True, PlotStyle -> Magenta, 
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt4 = ListPlot[orangepts, Frame -> True, PlotStyle -> Orange,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt5 = ListPlot[cyanpts, Frame -> True, PlotStyle -> Cyan,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt6 = ListPlot[redpts, Frame -> True, PlotStyle -> Red,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt7 = ListPlot[bluepts, Frame -> True, PlotStyle -> Blue,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt8 = ListPlot[greenpts, Frame -> True, PlotStyle -> Green,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt9 = ListPlot[lightgraypts, Frame -> True, PlotStyle -> LightGray,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt10 = ListPlot[yellowpts, Frame -> True, PlotStyle -> Yellow,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];

plt11 = ListPlot[blackpts, Frame -> True, PlotStyle -> Black,
GridLines -> dx, dy, PlotRange -> minx, maxx, miny, maxy,
AspectRatio -> 1];


This plot shows the nine-region cluster chart with the points colored by the region that they belong to :



finalchart = Show[plt3, plt4, plt5, plt6, plt7, plt8, plt9, plt10, plt11]


Mathematica graphics



Finally; we establish an association between the NAICS codes and their 2 - D points as follows:



mockdataWithNAICSlabels = 
Association[#[[1]] -> #[[2 ;; 3]] & /@ mockdataWithNAICS];

Dataset[mockdataWithNAICSlabels]


My question is: How can I associate the NAICS codes to their respective points BY COLORED REGION, so that if I use Tooltip; the NAICS codes will be displayed for each point in the above finalchart? Thank you!







plotting cluster-analysis






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









J. M. will be back soon

101k10 gold badges317 silver badges477 bronze badges




101k10 gold badges317 silver badges477 bronze badges










asked 10 hours ago









Gilmar Rodriguez PierluissiGilmar Rodriguez Pierluissi

7294 silver badges14 bronze badges




7294 silver badges14 bronze badges














  • $begingroup$
    Gilmar, a gentle reminder (if I may) re the comments following this post of yours re your previous questions
    $endgroup$
    – kglr
    10 hours ago










  • $begingroup$
    Dear Carl @kglr: I read your answer at the time and accepted your answer. I'm not sure what you are trying to tell me? That was a different topic (and post) altogether. Please, elaborate if you must.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago










  • $begingroup$
    @kglr How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago











  • $begingroup$
    @Carl Lange How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago











  • $begingroup$
    Thank you Gilmar. This is strange; you should be able accept/unaccept anytime. Perhaps this calls for developer/moderator attention to fix whatever is wrong with the pages you are seeing.
    $endgroup$
    – kglr
    8 hours ago
















  • $begingroup$
    Gilmar, a gentle reminder (if I may) re the comments following this post of yours re your previous questions
    $endgroup$
    – kglr
    10 hours ago










  • $begingroup$
    Dear Carl @kglr: I read your answer at the time and accepted your answer. I'm not sure what you are trying to tell me? That was a different topic (and post) altogether. Please, elaborate if you must.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago










  • $begingroup$
    @kglr How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago











  • $begingroup$
    @Carl Lange How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
    $endgroup$
    – Gilmar Rodriguez Pierluissi
    10 hours ago











  • $begingroup$
    Thank you Gilmar. This is strange; you should be able accept/unaccept anytime. Perhaps this calls for developer/moderator attention to fix whatever is wrong with the pages you are seeing.
    $endgroup$
    – kglr
    8 hours ago















$begingroup$
Gilmar, a gentle reminder (if I may) re the comments following this post of yours re your previous questions
$endgroup$
– kglr
10 hours ago




$begingroup$
Gilmar, a gentle reminder (if I may) re the comments following this post of yours re your previous questions
$endgroup$
– kglr
10 hours ago












$begingroup$
Dear Carl @kglr: I read your answer at the time and accepted your answer. I'm not sure what you are trying to tell me? That was a different topic (and post) altogether. Please, elaborate if you must.
$endgroup$
– Gilmar Rodriguez Pierluissi
10 hours ago




$begingroup$
Dear Carl @kglr: I read your answer at the time and accepted your answer. I'm not sure what you are trying to tell me? That was a different topic (and post) altogether. Please, elaborate if you must.
$endgroup$
– Gilmar Rodriguez Pierluissi
10 hours ago












$begingroup$
@kglr How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
$endgroup$
– Gilmar Rodriguez Pierluissi
10 hours ago





$begingroup$
@kglr How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
$endgroup$
– Gilmar Rodriguez Pierluissi
10 hours ago













$begingroup$
@Carl Lange How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
$endgroup$
– Gilmar Rodriguez Pierluissi
10 hours ago





$begingroup$
@Carl Lange How do I accept answers retro-actively? When I review my old posts there are no green check marks to be checked any more. As I made clear before; I learned about pressing the green check mark recently and I have done it ever since. I have NOT left the green check marks unchecked intentionally or with malice. Thank you.
$endgroup$
– Gilmar Rodriguez Pierluissi
10 hours ago













$begingroup$
Thank you Gilmar. This is strange; you should be able accept/unaccept anytime. Perhaps this calls for developer/moderator attention to fix whatever is wrong with the pages you are seeing.
$endgroup$
– kglr
8 hours ago




$begingroup$
Thank you Gilmar. This is strange; you should be able accept/unaccept anytime. Perhaps this calls for developer/moderator attention to fix whatever is wrong with the pages you are seeing.
$endgroup$
– kglr
8 hours ago










2 Answers
2






active

oldest

votes


















4














$begingroup$

I believe this has the intended functionality, with simplified code.



minx = Round[Min[mockdataWithNAICS[[All, 2]]]];
maxx = Round[Max[mockdataWithNAICS[[All, 2]]]];
dx = Round[Subdivide[minx, maxx, 3]];

miny = Round[Min[mockdataWithNAICS[[All, 3]]]];
maxy = Round[Max[mockdataWithNAICS[[All, 3]]]];
dy = Round[Subdivide[miny, maxy, 3]];

gridpts = Tuples[dx, dy];

regions =
Rectangle[gridpts[[1]], gridpts[[6]]],
Rectangle[gridpts[[5]], gridpts[[10]]],
Rectangle[gridpts[[9]], gridpts[[14]]],
Rectangle[gridpts[[2]], gridpts[[7]]],
Rectangle[gridpts[[6]], gridpts[[11]]],
Rectangle[gridpts[[10]], gridpts[[15]]],
Rectangle[gridpts[[3]], gridpts[[8]]],
Rectangle[gridpts[[7]], gridpts[[12]]],
Rectangle[gridpts[[11]], gridpts[[16]]];

pts = Table[
Select[mockdataWithNAICS, #[[2, 3]] [Element] r &], r, regions];

colors = Magenta, Orange, Cyan, Red, Blue, Green, LightGray, Yellow,
Black;

ListPlot[Table[Tooltip[#[[2, 3]], #[[1]]] & /@ p, p, pts],
Frame -> True, PlotStyle -> colors, GridLines -> dx, dy,
PlotRange -> minx, maxx, miny, maxy, AspectRatio -> 1]


enter image description here






share|improve this answer











$endgroup$






















    2














    $begingroup$

    colors = Magenta, Orange, Cyan, Red, Blue, Green, LightGray, Yellow, Black;

    tooltips = ##2 -> Tooltip[##2, #] & @@@ mockdataWithNAICS;

    dx, dy = Round[Subdivide[##, 3]] & @@@ (Round[MinMax@#] & /@
    Transpose[mockdataWithNAICS[[All, 2, 3]]]);


    You can use BinLists with dx and dy as horizontal and vertical bin delimiters to group the data into bins:



    binlists = Join @@ BinLists[mockdataWithNAICS[[All, 2, 3]], dx, dy];


    and use a single ListPlot to plot all groups:



    ListPlot[binlists /. tooltips, 
    Frame -> True,
    PlotStyle -> colors,
    GridLines -> dx, dy,
    BaseStyle -> PointSize[Large],
    Axes -> False,
    AspectRatio -> 1,
    PlotRange -> -10, 710, -10, 710]


    enter image description here



    With a minor modification in tooltips, you can also use BubbleChart



    tooltips2 = ##2 -> Tooltip[##2, 1, #] & @@@ mockdataWithNAICS;

    BubbleChart[binlists /. tooltips2,
    Frame -> True,
    ChartStyle -> colors,
    GridLines -> dx, dy,
    Axes -> False,
    BubbleSizes -> .02, .02,
    PlotRange -> -10, 710, -10, 710]


    enter image description here






    share|improve this answer











    $endgroup$

















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "387"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );














      draft saved

      draft discarded
















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f206572%2fbuilding-a-nine-region-cluster-chart-with-tooltip-to-display-labels-associated%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      4














      $begingroup$

      I believe this has the intended functionality, with simplified code.



      minx = Round[Min[mockdataWithNAICS[[All, 2]]]];
      maxx = Round[Max[mockdataWithNAICS[[All, 2]]]];
      dx = Round[Subdivide[minx, maxx, 3]];

      miny = Round[Min[mockdataWithNAICS[[All, 3]]]];
      maxy = Round[Max[mockdataWithNAICS[[All, 3]]]];
      dy = Round[Subdivide[miny, maxy, 3]];

      gridpts = Tuples[dx, dy];

      regions =
      Rectangle[gridpts[[1]], gridpts[[6]]],
      Rectangle[gridpts[[5]], gridpts[[10]]],
      Rectangle[gridpts[[9]], gridpts[[14]]],
      Rectangle[gridpts[[2]], gridpts[[7]]],
      Rectangle[gridpts[[6]], gridpts[[11]]],
      Rectangle[gridpts[[10]], gridpts[[15]]],
      Rectangle[gridpts[[3]], gridpts[[8]]],
      Rectangle[gridpts[[7]], gridpts[[12]]],
      Rectangle[gridpts[[11]], gridpts[[16]]];

      pts = Table[
      Select[mockdataWithNAICS, #[[2, 3]] [Element] r &], r, regions];

      colors = Magenta, Orange, Cyan, Red, Blue, Green, LightGray, Yellow,
      Black;

      ListPlot[Table[Tooltip[#[[2, 3]], #[[1]]] & /@ p, p, pts],
      Frame -> True, PlotStyle -> colors, GridLines -> dx, dy,
      PlotRange -> minx, maxx, miny, maxy, AspectRatio -> 1]


      enter image description here






      share|improve this answer











      $endgroup$



















        4














        $begingroup$

        I believe this has the intended functionality, with simplified code.



        minx = Round[Min[mockdataWithNAICS[[All, 2]]]];
        maxx = Round[Max[mockdataWithNAICS[[All, 2]]]];
        dx = Round[Subdivide[minx, maxx, 3]];

        miny = Round[Min[mockdataWithNAICS[[All, 3]]]];
        maxy = Round[Max[mockdataWithNAICS[[All, 3]]]];
        dy = Round[Subdivide[miny, maxy, 3]];

        gridpts = Tuples[dx, dy];

        regions =
        Rectangle[gridpts[[1]], gridpts[[6]]],
        Rectangle[gridpts[[5]], gridpts[[10]]],
        Rectangle[gridpts[[9]], gridpts[[14]]],
        Rectangle[gridpts[[2]], gridpts[[7]]],
        Rectangle[gridpts[[6]], gridpts[[11]]],
        Rectangle[gridpts[[10]], gridpts[[15]]],
        Rectangle[gridpts[[3]], gridpts[[8]]],
        Rectangle[gridpts[[7]], gridpts[[12]]],
        Rectangle[gridpts[[11]], gridpts[[16]]];

        pts = Table[
        Select[mockdataWithNAICS, #[[2, 3]] [Element] r &], r, regions];

        colors = Magenta, Orange, Cyan, Red, Blue, Green, LightGray, Yellow,
        Black;

        ListPlot[Table[Tooltip[#[[2, 3]], #[[1]]] & /@ p, p, pts],
        Frame -> True, PlotStyle -> colors, GridLines -> dx, dy,
        PlotRange -> minx, maxx, miny, maxy, AspectRatio -> 1]


        enter image description here






        share|improve this answer











        $endgroup$

















          4














          4










          4







          $begingroup$

          I believe this has the intended functionality, with simplified code.



          minx = Round[Min[mockdataWithNAICS[[All, 2]]]];
          maxx = Round[Max[mockdataWithNAICS[[All, 2]]]];
          dx = Round[Subdivide[minx, maxx, 3]];

          miny = Round[Min[mockdataWithNAICS[[All, 3]]]];
          maxy = Round[Max[mockdataWithNAICS[[All, 3]]]];
          dy = Round[Subdivide[miny, maxy, 3]];

          gridpts = Tuples[dx, dy];

          regions =
          Rectangle[gridpts[[1]], gridpts[[6]]],
          Rectangle[gridpts[[5]], gridpts[[10]]],
          Rectangle[gridpts[[9]], gridpts[[14]]],
          Rectangle[gridpts[[2]], gridpts[[7]]],
          Rectangle[gridpts[[6]], gridpts[[11]]],
          Rectangle[gridpts[[10]], gridpts[[15]]],
          Rectangle[gridpts[[3]], gridpts[[8]]],
          Rectangle[gridpts[[7]], gridpts[[12]]],
          Rectangle[gridpts[[11]], gridpts[[16]]];

          pts = Table[
          Select[mockdataWithNAICS, #[[2, 3]] [Element] r &], r, regions];

          colors = Magenta, Orange, Cyan, Red, Blue, Green, LightGray, Yellow,
          Black;

          ListPlot[Table[Tooltip[#[[2, 3]], #[[1]]] & /@ p, p, pts],
          Frame -> True, PlotStyle -> colors, GridLines -> dx, dy,
          PlotRange -> minx, maxx, miny, maxy, AspectRatio -> 1]


          enter image description here






          share|improve this answer











          $endgroup$



          I believe this has the intended functionality, with simplified code.



          minx = Round[Min[mockdataWithNAICS[[All, 2]]]];
          maxx = Round[Max[mockdataWithNAICS[[All, 2]]]];
          dx = Round[Subdivide[minx, maxx, 3]];

          miny = Round[Min[mockdataWithNAICS[[All, 3]]]];
          maxy = Round[Max[mockdataWithNAICS[[All, 3]]]];
          dy = Round[Subdivide[miny, maxy, 3]];

          gridpts = Tuples[dx, dy];

          regions =
          Rectangle[gridpts[[1]], gridpts[[6]]],
          Rectangle[gridpts[[5]], gridpts[[10]]],
          Rectangle[gridpts[[9]], gridpts[[14]]],
          Rectangle[gridpts[[2]], gridpts[[7]]],
          Rectangle[gridpts[[6]], gridpts[[11]]],
          Rectangle[gridpts[[10]], gridpts[[15]]],
          Rectangle[gridpts[[3]], gridpts[[8]]],
          Rectangle[gridpts[[7]], gridpts[[12]]],
          Rectangle[gridpts[[11]], gridpts[[16]]];

          pts = Table[
          Select[mockdataWithNAICS, #[[2, 3]] [Element] r &], r, regions];

          colors = Magenta, Orange, Cyan, Red, Blue, Green, LightGray, Yellow,
          Black;

          ListPlot[Table[Tooltip[#[[2, 3]], #[[1]]] & /@ p, p, pts],
          Frame -> True, PlotStyle -> colors, GridLines -> dx, dy,
          PlotRange -> minx, maxx, miny, maxy, AspectRatio -> 1]


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 8 hours ago

























          answered 8 hours ago









          MelaGoMelaGo

          2,9111 gold badge2 silver badges8 bronze badges




          2,9111 gold badge2 silver badges8 bronze badges


























              2














              $begingroup$

              colors = Magenta, Orange, Cyan, Red, Blue, Green, LightGray, Yellow, Black;

              tooltips = ##2 -> Tooltip[##2, #] & @@@ mockdataWithNAICS;

              dx, dy = Round[Subdivide[##, 3]] & @@@ (Round[MinMax@#] & /@
              Transpose[mockdataWithNAICS[[All, 2, 3]]]);


              You can use BinLists with dx and dy as horizontal and vertical bin delimiters to group the data into bins:



              binlists = Join @@ BinLists[mockdataWithNAICS[[All, 2, 3]], dx, dy];


              and use a single ListPlot to plot all groups:



              ListPlot[binlists /. tooltips, 
              Frame -> True,
              PlotStyle -> colors,
              GridLines -> dx, dy,
              BaseStyle -> PointSize[Large],
              Axes -> False,
              AspectRatio -> 1,
              PlotRange -> -10, 710, -10, 710]


              enter image description here



              With a minor modification in tooltips, you can also use BubbleChart



              tooltips2 = ##2 -> Tooltip[##2, 1, #] & @@@ mockdataWithNAICS;

              BubbleChart[binlists /. tooltips2,
              Frame -> True,
              ChartStyle -> colors,
              GridLines -> dx, dy,
              Axes -> False,
              BubbleSizes -> .02, .02,
              PlotRange -> -10, 710, -10, 710]


              enter image description here






              share|improve this answer











              $endgroup$



















                2














                $begingroup$

                colors = Magenta, Orange, Cyan, Red, Blue, Green, LightGray, Yellow, Black;

                tooltips = ##2 -> Tooltip[##2, #] & @@@ mockdataWithNAICS;

                dx, dy = Round[Subdivide[##, 3]] & @@@ (Round[MinMax@#] & /@
                Transpose[mockdataWithNAICS[[All, 2, 3]]]);


                You can use BinLists with dx and dy as horizontal and vertical bin delimiters to group the data into bins:



                binlists = Join @@ BinLists[mockdataWithNAICS[[All, 2, 3]], dx, dy];


                and use a single ListPlot to plot all groups:



                ListPlot[binlists /. tooltips, 
                Frame -> True,
                PlotStyle -> colors,
                GridLines -> dx, dy,
                BaseStyle -> PointSize[Large],
                Axes -> False,
                AspectRatio -> 1,
                PlotRange -> -10, 710, -10, 710]


                enter image description here



                With a minor modification in tooltips, you can also use BubbleChart



                tooltips2 = ##2 -> Tooltip[##2, 1, #] & @@@ mockdataWithNAICS;

                BubbleChart[binlists /. tooltips2,
                Frame -> True,
                ChartStyle -> colors,
                GridLines -> dx, dy,
                Axes -> False,
                BubbleSizes -> .02, .02,
                PlotRange -> -10, 710, -10, 710]


                enter image description here






                share|improve this answer











                $endgroup$

















                  2














                  2










                  2







                  $begingroup$

                  colors = Magenta, Orange, Cyan, Red, Blue, Green, LightGray, Yellow, Black;

                  tooltips = ##2 -> Tooltip[##2, #] & @@@ mockdataWithNAICS;

                  dx, dy = Round[Subdivide[##, 3]] & @@@ (Round[MinMax@#] & /@
                  Transpose[mockdataWithNAICS[[All, 2, 3]]]);


                  You can use BinLists with dx and dy as horizontal and vertical bin delimiters to group the data into bins:



                  binlists = Join @@ BinLists[mockdataWithNAICS[[All, 2, 3]], dx, dy];


                  and use a single ListPlot to plot all groups:



                  ListPlot[binlists /. tooltips, 
                  Frame -> True,
                  PlotStyle -> colors,
                  GridLines -> dx, dy,
                  BaseStyle -> PointSize[Large],
                  Axes -> False,
                  AspectRatio -> 1,
                  PlotRange -> -10, 710, -10, 710]


                  enter image description here



                  With a minor modification in tooltips, you can also use BubbleChart



                  tooltips2 = ##2 -> Tooltip[##2, 1, #] & @@@ mockdataWithNAICS;

                  BubbleChart[binlists /. tooltips2,
                  Frame -> True,
                  ChartStyle -> colors,
                  GridLines -> dx, dy,
                  Axes -> False,
                  BubbleSizes -> .02, .02,
                  PlotRange -> -10, 710, -10, 710]


                  enter image description here






                  share|improve this answer











                  $endgroup$



                  colors = Magenta, Orange, Cyan, Red, Blue, Green, LightGray, Yellow, Black;

                  tooltips = ##2 -> Tooltip[##2, #] & @@@ mockdataWithNAICS;

                  dx, dy = Round[Subdivide[##, 3]] & @@@ (Round[MinMax@#] & /@
                  Transpose[mockdataWithNAICS[[All, 2, 3]]]);


                  You can use BinLists with dx and dy as horizontal and vertical bin delimiters to group the data into bins:



                  binlists = Join @@ BinLists[mockdataWithNAICS[[All, 2, 3]], dx, dy];


                  and use a single ListPlot to plot all groups:



                  ListPlot[binlists /. tooltips, 
                  Frame -> True,
                  PlotStyle -> colors,
                  GridLines -> dx, dy,
                  BaseStyle -> PointSize[Large],
                  Axes -> False,
                  AspectRatio -> 1,
                  PlotRange -> -10, 710, -10, 710]


                  enter image description here



                  With a minor modification in tooltips, you can also use BubbleChart



                  tooltips2 = ##2 -> Tooltip[##2, 1, #] & @@@ mockdataWithNAICS;

                  BubbleChart[binlists /. tooltips2,
                  Frame -> True,
                  ChartStyle -> colors,
                  GridLines -> dx, dy,
                  Axes -> False,
                  BubbleSizes -> .02, .02,
                  PlotRange -> -10, 710, -10, 710]


                  enter image description here







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 5 hours ago

























                  answered 5 hours ago









                  kglrkglr

                  218k10 gold badges248 silver badges499 bronze badges




                  218k10 gold badges248 silver badges499 bronze badges































                      draft saved

                      draft discarded















































                      Thanks for contributing an answer to Mathematica Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f206572%2fbuilding-a-nine-region-cluster-chart-with-tooltip-to-display-labels-associated%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу

                      Israel Cuprins Etimologie | Istorie | Geografie | Politică | Demografie | Educație | Economie | Cultură | Note explicative | Note bibliografice | Bibliografie | Legături externe | Meniu de navigaresite web oficialfacebooktweeterGoogle+Instagramcanal YouTubeInstagramtextmodificaremodificarewww.technion.ac.ilnew.huji.ac.ilwww.weizmann.ac.ilwww1.biu.ac.ilenglish.tau.ac.ilwww.haifa.ac.ilin.bgu.ac.ilwww.openu.ac.ilwww.ariel.ac.ilCIA FactbookHarta Israelului"Negotiating Jerusalem," Palestine–Israel JournalThe Schizoid Nature of Modern Hebrew: A Slavic Language in Search of a Semitic Past„Arabic in Israel: an official language and a cultural bridge”„Latest Population Statistics for Israel”„Israel Population”„Tables”„Report for Selected Countries and Subjects”Human Development Report 2016: Human Development for Everyone„Distribution of family income - Gini index”The World FactbookJerusalem Law„Israel”„Israel”„Zionist Leaders: David Ben-Gurion 1886–1973”„The status of Jerusalem”„Analysis: Kadima's big plans”„Israel's Hard-Learned Lessons”„The Legacy of Undefined Borders, Tel Aviv Notes No. 40, 5 iunie 2002”„Israel Journal: A Land Without Borders”„Population”„Israel closes decade with population of 7.5 million”Time Series-DataBank„Selected Statistics on Jerusalem Day 2007 (Hebrew)”Golan belongs to Syria, Druze protestGlobal Survey 2006: Middle East Progress Amid Global Gains in FreedomWHO: Life expectancy in Israel among highest in the worldInternational Monetary Fund, World Economic Outlook Database, April 2011: Nominal GDP list of countries. Data for the year 2010.„Israel's accession to the OECD”Popular Opinion„On the Move”Hosea 12:5„Walking the Bible Timeline”„Palestine: History”„Return to Zion”An invention called 'the Jewish people' – Haaretz – Israel NewsoriginalJewish and Non-Jewish Population of Palestine-Israel (1517–2004)ImmigrationJewishvirtuallibrary.orgChapter One: The Heralders of Zionism„The birth of modern Israel: A scrap of paper that changed history”„League of Nations: The Mandate for Palestine, 24 iulie 1922”The Population of Palestine Prior to 1948originalBackground Paper No. 47 (ST/DPI/SER.A/47)History: Foreign DominationTwo Hundred and Seventh Plenary Meeting„Israel (Labor Zionism)”Population, by Religion and Population GroupThe Suez CrisisAdolf EichmannJustice Ministry Reply to Amnesty International Report„The Interregnum”Israel Ministry of Foreign Affairs – The Palestinian National Covenant- July 1968Research on terrorism: trends, achievements & failuresThe Routledge Atlas of the Arab–Israeli conflict: The Complete History of the Struggle and the Efforts to Resolve It"George Habash, Palestinian Terrorism Tactician, Dies at 82."„1973: Arab states attack Israeli forces”Agranat Commission„Has Israel Annexed East Jerusalem?”original„After 4 Years, Intifada Still Smolders”From the End of the Cold War to 2001originalThe Oslo Accords, 1993Israel-PLO Recognition – Exchange of Letters between PM Rabin and Chairman Arafat – Sept 9- 1993Foundation for Middle East PeaceSources of Population Growth: Total Israeli Population and Settler Population, 1991–2003original„Israel marks Rabin assassination”The Wye River Memorandumoriginal„West Bank barrier route disputed, Israeli missile kills 2”"Permanent Ceasefire to Be Based on Creation Of Buffer Zone Free of Armed Personnel Other than UN, Lebanese Forces"„Hezbollah kills 8 soldiers, kidnaps two in offensive on northern border”„Olmert confirms peace talks with Syria”„Battleground Gaza: Israeli ground forces invade the strip”„IDF begins Gaza troop withdrawal, hours after ending 3-week offensive”„THE LAND: Geography and Climate”„Area of districts, sub-districts, natural regions and lakes”„Israel - Geography”„Makhteshim Country”Israel and the Palestinian Territories„Makhtesh Ramon”„The Living Dead Sea”„Temperatures reach record high in Pakistan”„Climate Extremes In Israel”Israel in figures„Deuteronom”„JNF: 240 million trees planted since 1901”„Vegetation of Israel and Neighboring Countries”Environmental Law in Israel„Executive branch”„Israel's election process explained”„The Electoral System in Israel”„Constitution for Israel”„All 120 incoming Knesset members”„Statul ISRAEL”„The Judiciary: The Court System”„Israel's high court unique in region”„Israel and the International Criminal Court: A Legal Battlefield”„Localities and population, by population group, district, sub-district and natural region”„Israel: Districts, Major Cities, Urban Localities & Metropolitan Areas”„Israel-Egypt Relations: Background & Overview of Peace Treaty”„Solana to Haaretz: New Rules of War Needed for Age of Terror”„Israel's Announcement Regarding Settlements”„United Nations Security Council Resolution 497”„Security Council resolution 478 (1980) on the status of Jerusalem”„Arabs will ask U.N. to seek razing of Israeli wall”„Olmert: Willing to trade land for peace”„Mapping Peace between Syria and Israel”„Egypt: Israel must accept the land-for-peace formula”„Israel: Age structure from 2005 to 2015”„Global, regional, and national disability-adjusted life years (DALYs) for 306 diseases and injuries and healthy life expectancy (HALE) for 188 countries, 1990–2013: quantifying the epidemiological transition”10.1016/S0140-6736(15)61340-X„World Health Statistics 2014”„Life expectancy for Israeli men world's 4th highest”„Family Structure and Well-Being Across Israel's Diverse Population”„Fertility among Jewish and Muslim Women in Israel, by Level of Religiosity, 1979-2009”„Israel leaders in birth rate, but poverty major challenge”„Ethnic Groups”„Israel's population: Over 8.5 million”„Israel - Ethnic groups”„Jews, by country of origin and age”„Minority Communities in Israel: Background & Overview”„Israel”„Language in Israel”„Selected Data from the 2011 Social Survey on Mastery of the Hebrew Language and Usage of Languages”„Religions”„5 facts about Israeli Druze, a unique religious and ethnic group”„Israël”Israel Country Study Guide„Haredi city in Negev – blessing or curse?”„New town Harish harbors hopes of being more than another Pleasantville”„List of localities, in alphabetical order”„Muncitorii români, doriți în Israel”„Prietenia româno-israeliană la nevoie se cunoaște”„The Higher Education System in Israel”„Middle East”„Academic Ranking of World Universities 2016”„Israel”„Israel”„Jewish Nobel Prize Winners”„All Nobel Prizes in Literature”„All Nobel Peace Prizes”„All Prizes in Economic Sciences”„All Nobel Prizes in Chemistry”„List of Fields Medallists”„Sakharov Prize”„Țara care și-a sfidat "destinul" și se bate umăr la umăr cu Silicon Valley”„Apple's R&D center in Israel grew to about 800 employees”„Tim Cook: Apple's Herzliya R&D center second-largest in world”„Lecții de economie de la Israel”„Land use”Israel Investment and Business GuideA Country Study: IsraelCentral Bureau of StatisticsFlorin Diaconu, „Kadima: Flexibilitate și pragmatism, dar nici un compromis în chestiuni vitale", în Revista Institutului Diplomatic Român, anul I, numărul I, semestrul I, 2006, pp. 71-72Florin Diaconu, „Likud: Dreapta israeliană constant opusă retrocedării teritoriilor cureite prin luptă în 1967", în Revista Institutului Diplomatic Român, anul I, numărul I, semestrul I, 2006, pp. 73-74MassadaIsraelul a crescut in 50 de ani cât alte state intr-un mileniuIsrael Government PortalIsraelIsraelIsraelmmmmmXX451232cb118646298(data)4027808-634110000 0004 0372 0767n7900328503691455-bb46-37e3-91d2-cb064a35ffcc1003570400564274ge1294033523775214929302638955X146498911146498911

                      Кастелфранко ди Сопра Становништво Референце Спољашње везе Мени за навигацију43°37′18″ СГШ; 11°33′32″ ИГД / 43.62156° СГШ; 11.55885° ИГД / 43.62156; 11.5588543°37′18″ СГШ; 11°33′32″ ИГД / 43.62156° СГШ; 11.55885° ИГД / 43.62156; 11.558853179688„The GeoNames geographical database”„Istituto Nazionale di Statistica”проширитиууWorldCat156923403n850174324558639-1cb14643287r(подаци)