# proper way to scale and plot data points on top of each other

I hope this is the right place that I am posting this question. If not please feel free to comment so that I find the right place. I have 4 sets of points that represent points on hexagons. My data points are such that when I plot them , hexagons are next to each other, but I want to plot each hexagon on top of each other (stack them on top of each other) , So that I compare them and do further analysis.

Image 1 shows the data points

Image 2 shows the resulting plots

But this is not what I want, I want all points to be rescaled such that they are on top of each other something like following image :

This is just an example. What is the best way to re-scale data points for each hexagon, mathematically? I don't want a code. I believe there must be a way to scale all data point to a reference data set (for instance a perfect hexagon).

I was thinking to normalize my points using feature scaling formula (x'=X-Xmin/Xmax-Xmin), but it will only change the scale of the coordinates and the hexagons will still be next to each other. Also I was thinking to find equation of lines and plot the lines and lengths. I feel like there is a way by defining a fixed hexagon and find deviation of each point of my data from that fixed hexagon, or maybe there is some other formula.

here is a copy of data points if you need,

Number x_1st y_1st x_2nd y_2nd x_3rd y_3rd x_4th y_4th

1 655.333 17.167 654.5 27.5 652 36.833 649.812 47.5

2 649.333 9.833 648.167 21.167 646 30.125 643.812 39.438

3 642.167 13.667 638.5 23.833 636.438 32.812 634.75 43.688

4 639.167 23 636.5 32.5 635 43.438 632.625 52.75

5 646.167 29.833 644 39.167 641.438 50 638.25 59.062

6 653.833 27.5 652.167 36.167 650 47.25 648.125 57.75

7 655.333 17.167 654.5 27.5 652 36.833 649.812 47.5

1. Calculate the center of all the data.
2. Calculate the center of each set.
3. Offset each set to center them within the plotting area.

We don't offer programming help in this answer, but I'll use code to explain the answer's appearance. Pseudocode, incomplete non-working example:

/* Calculate the center of all the data. */
MaxX = 655; MinX = 632; MidX = (MaxX + MinX) / 2;
MaxY = 60; MinY = 10; MidY = (MaxY + MinY) / 2;

/* Calculate the center of each set. */
/ * Shown for the first one only, use a loop to calculate for all four. */
X_1_A = (x_1st(1) - x_1st(4)) / 2;
X_1_B = (x_1st(2) - x_1st(5)) / 2;
X_1_C = (x_1st(3) - x_1st(6)) / 2;
X_1 = Average (X_1_A, X_1_B, X_1_C);

Y_1_A = (y_1st(1) - y_1st(4)) / 2;
Y_1_B = (y_1st(2) - y_1st(5)) / 2;
Y_1_C = (y_1st(3) - y_1st(6)) / 2;
Y_1 = Average (Y_1_A, Y_1_B, Y_1_C);

/* Now loop back for each one, not shown to reduce complexity of multiple indexes */

/* Now add X_1 and Y_1 to the values of x_1st(1 to 6) and y_1st(1 to 6) */

/* Do the same for: x_2nd y_2nd x_3rd y_3rd x_4th y_4th (for 3rd and 4th value it will offset left) */

All four should be centered on approximately:
X = ((660 - 625) / 2) + 625 = 642.5
Y = ((60 - 10) / 2) + 10 = 35
or MidX and MidY, depending on preferance to chart domain or data domain centering.

When you change the data and the range graphed you should still end up with your data sets centered. That proves you've written the algorithm correctly without dependencies on the data (as there are in the example).

The correct way, to preserve all the data rather than move or scale, is to rotate on each axis until the objects overlap as much as possible; you might additionally rotate each set to flatten it. Here is rotation on one axis, if you had wrote your example in Octave there are online plotters which everyone could use to offer an answer. One more rotation and they will sit on top of each other.

• Thanks for reply, I followed the steps, it seems that it also shifts the values and hexagons are still not uni-central (not appended on top of each other). Is there something missing? In the beginning of your algorithm, you have some statistics (such as MidX , MidY), yet you didn't use those values. Also, I think in line 13 of your algorithm, you mean Y_1 = Average (Y_1_A, Y_1_B, Y_1_C) Commented Apr 3, 2019 at 4:46
• Yes, that line was the result of a copy/paste error; and not editing that line. The difficulties of using a Cellphone, tunnel vision. The answer offered is to assist you with "data visualization" which is on topic, unfortunately "programming" is off topic, so an exact example wasn't offered (because if you wanted help programming this would get closed). I've done a bit of editing, perhaps read the 123 part and the bit that I moved out of the yellow.
– Rob
Commented Apr 3, 2019 at 5:03
• I think my question is not clear, I apologize for that. I don't want a code to plot or rotate axis. I need a mathematical formula or a technique to scale all the data so the hexagons stack on top of each other. I edited the question and posted what I am expecting to get. Commented Apr 3, 2019 at 16:38
• @RacaioCmoto Thanks for editing to clairify your answer. What I first suggested would make them overlap, but not increase their size to fill the available area. My second point was that doing so alters the values significantly, you go from comparing values to comparing shapes. That's why I suggested rotation, it doesn't alter the values and still allows them to overlap. I'm going to let others invest themselves in this and move onto something else if you don't see how to apply my answer to your question.
– Rob
Commented Apr 3, 2019 at 17:19