散点图绘制教程:随机坐标点生成与可视化

散点图绘制教程:随机坐标点生成与可视化
几何画板及绘图内容加载中,请稍等……
2023-08-15 22:00
本范例演示如何在GeoGebra中创建散点图并可视化随机生成的坐标点数据。核心数学概念包括坐标平面、随机数生成、点列操作与数据统计可视化。作图要点:使用Random命令族生成随机坐标点数据,通过Sequence和Zip批量创建点对象,借助Flatten整理数据格式,用Sort和Unique实现数据去重与排序,结合Polygon和Segment绘制数据特征线,可通过Slider添加交互式动画效果。本范例适合中学数学的统计与概率教学、大学预科数据分析入门,以及GeoGebra命令学习的实践案例。

GeoGebra 命令及参数

  1. Flatten(Sequence[Sequence[1, 3], n, 1, 33]) → randomProbs
  2. Element(randomProbs, Mod[countQuestion, 99] + 1) → randomProb
  3. PixelsToPoint(Corner[1], Corner[3], Corner[5], (11 + 5, 154)) → CornerLeftTable
  4. Shuffle(Sequence[Random[-100, 100] / 10, i, 1, 102]) → randomMult, {-2.3, -2.3, -4.8, 6.5, 5.9, 2.9, -7.7, -3.5, 5.7, 2.9, 2.2, -0.3, 7.7, 0.5, -1.7, -1.3, -9.9, -5.3, -5.2, -9.2, 7.3, 4.3, 0.7, 6.1, 4.5, -0.4, -9.7, 9.3, 2.8, 4.7, -9.3, -8.6, -8, -2.1, -1.5, 6.1, 4.6, 4, -2.2, -2.9, 9.5, 8.4, -1, 3.8, -4.2, -5.7, 6.9, -8.4, -7.9, 5.2, 2.3, -5.2, -6.9, -5, -2, 0.9, -3.8, -6.7, 8.5, 6.4, 0, -4.2, -5.7, 8, 2.5, 1.6, 5.9, -3.1, 3.1, 9.5, -4.5, -7.7, -0.7, 6, 4.9, -5.4, -3.7, 6.9, -0.6, 7.4, -3.3, -9, 5.5, -1, -0.6, -1.9, -0.3, 2.7, -7.1, -0.2, 8.5, 10, 9.4, -6.1, 1.8, 5, 4, 1.2, 9.1, -8.5, -6.9, -1.8}
  5. Shuffle(Sequence[Random[10, 20], i, 1, 102]) → randomRecip, {19, 13, 19, 13, 17, 10, 18, 18, 10, 17, 20, 15, 18, 11, 19, 17, 19, 14, 13, 19, 20, 14, 17, 15, 17, 18, 14, 12, 17, 14, 18, 15, 20, 12, 10, 15, 14, 20, 11, 14, 12, 15, 12, 14, 11, 13, 16, 13, 10, 17, 14, 18, 13, 16, 13, 19, 19, 12, 19, 20, 13, 17, 14, 12, 10, 17, 16, 14, 13, 13, 17, 13, 16, 15, 18, 18, 15, 10, 13, 12, 12, 11, 13, 11, 19, 19, 16, 11, 14, 17, 18, 20, 13, 16, 15, 15, 17, 14, 11, 18, 15, 17}
  6. Shuffle(Sequence[Random[0, 60] / 10, i, 1, 102]) → randomXH, {3.8, 1.2, 0.5, 4.5, 5.7, 0.4, 1.5, 6, 0.6, 3, 0.5, 4, 1.3, 2.8, 5.7, 2.3, 3.9, 3.1, 0.8, 5.3, 5.9, 0, 1, 1.2, 1.9, 0.8, 4.3, 3.3, 4.4, 5.3, 2.4, 2.3, 2.2, 0.7, 4.9, 1.2, 4.9, 0.6, 1.5, 0, 2.8, 4.4, 0.2, 5, 3.3, 2.9, 1.1, 0.8, 2.1, 5.3, 5.4, 2.1, 0.2, 2.2, 5.4, 3.5, 1.9, 2.2, 4.8, 5.3, 0.8, 0.6, 2, 0.3, 5.6, 0, 0.3, 0.9, 2.3, 3.3, 3.7, 5.9, 2.4, 4.2, 4.1, 4.3, 0.4, 1.1, 0.6, 2.3, 3.3, 5.4, 1, 1, 4.4, 2.2, 1.3, 0.7, 0.7, 1.5, 5.9, 4.9, 4.9, 4, 5, 4.1, 3.6, 0.5, 6, 0.1, 0.2, 4.4}
  7. Shuffle(Sequence[Random[100, 138] / 10, n, 1, 100]) → randomSlopes1, {12.5, 12.6, 12.9, 13.7, 10.2, 13.6, 11.2, 11.3, 12.5, 10.9, 12.7, 12.2, 12.2, 13.3, 11.7, 10.4, 13, 10.7, 10.3, 12.2, 12.5, 12.7, 13, 12.4, 12.4, 10, 11.5, 11.9, 10.7, 10.5, 10, 12.9, 12.5, 12.6, 12.1, 11.1, 13.1, 10.8, 12.7, 10.3, 10.4, 11.7, 13, 13.4, 13.2, 11.6, 13.6, 13.2, 11.2, 10.3, 10.4, 13.2, 11.7, 12.2, 10.2, 13.8, 12.8, 12, 13.3, 10, 13.3, 11.9, 11.3, 11.6, 12.3, 11.7, 11.8, 11.4, 11.8, 13.5, 12.7, 12.4, 10.7, 12.6, 13.1, 13, 11, 12.8, 10.6, 12, 12.8, 11.4, 12.9, 11, 11.6, 11.9, 12.2, 13.2, 13.5, 12.6, 13.7, 13.1, 12.4, 12.4, 12.7, 10.4, 11.7, 10.3, 11.8, 12.6}
  8. Element(randomSlopes1, Mod[countQuestion, 100] + 1) → randomSlope1
  9. Shuffle(Sequence[Random[-32, -20] / 10, n, 1, 100]) → randomSlopes2, {-2.9, -2.2, -2.7, -2.8, -2.8, -2.9, -2.7, -2.9, -3.2, -2.2, -2.7, -2.4, -2.8, -2, -3, -2.3, -2.8, -3.1, -2, -2.1, -2.9, -2.7, -2.2, -2.4, -2.7, -2.8, -2.5, -2.4, -2.4, -2.1, -2, -2.2, -2.9, -2.3, -2.9, -2.7, -2.9, -2.6, -2.9, -2.6, -2, -2.8, -2, -2.9, -3.1, -2.5, -2.8, -3, -2, -2.8, -3, -2.2, -3, -2, -2.4, -2.9, -2.4, -2.4, -2.2, -2.2, -2.5, -2, -2.6, -3.2, -2.3, -2.7, -2.2, -3.2, -3.1, -2.8, -3.1, -2, -2.3, -2.5, -2.9, -2, -2.7, -2.1, -2.4, -3, -2.2, -2, -2.4, -2.7, -2.2, -2.3, -2.1, -2.9, -2.4, -3.1, -2.4, -2.9, -2.3, -3.2, -2.4, -2.1, -3, -2.3, -2.6, -2.7}
  10. Element(randomSlopes2, Mod[countQuestion, 100] + 1) → randomSlope2
  11. Shuffle(Sequence[Random[1, 6], n, 1, 102]) → problem3x, {6, 5, 3, 5, 3, 4, 4, 2, 5, 2, 6, 1, 2, 1, 4, 1, 6, 4, 1, 5, 2, 5, 6, 5, 2, 4, 6, 6, 3, 3, 4, 3, 6, 5, 5, 5, 3, 6, 6, 5, 6, 4, 6, 5, 4, 1, 1, 2, 4, 2, 6, 1, 3, 4, 6, 1, 4, 4, 5, 4, 5, 3, 4, 4, 4, 1, 5, 3, 4, 5, 2, 2, 5, 2, 4, 3, 2, 2, 6, 5, 5, 5, 5, 2, 1, 1, 5, 5, 3, 6, 6, 2, 3, 1, 5, 6, 1, 4, 1, 1, 5, 5}
  12. Shuffle(Sequence[(round(Random[20, 100] / 5) * 5), n, 1, 102]) → problem3y, {60, 25, 40, 85, 70, 40, 45, 35, 65, 20, 20, 80, 75, 55, 85, 65, 60, 100, 25, 45, 85, 60, 95, 85, 65, 95, 45, 45, 60, 95, 40, 40, 65, 95, 55, 45, 90, 80, 20, 65, 65, 90, 75, 80, 100, 40, 80, 90, 50, 45, 65, 65, 100, 55, 70, 40, 50, 60, 35, 30, 40, 75, 35, 90, 30, 35, 25, 85, 25, 40, 65, 75, 40, 80, 40, 50, 30, 85, 25, 75, 100, 50, 90, 45, 55, 25, 35, 25, 70, 85, 35, 20, 30, 80, 35, 65, 95, 25, 25, 70, 40, 60}
  13. Unique(randomPoints3) → randomPoints3U
  14. Length(randomPoints3U) → lengthUnique3
  15. If(6 < Mod[(6 * (countQuestion + 1)), lengthUnique3] < lengthUnique3, Take[randomPoints3U, Mod[(6 * countQuestion), lengthUnique3] + 1, Mod[(6 * (countQuestion + 1)), lengthUnique3]], Mod[(6 * (countQuestion + 1)), lengthUnique3] ≟ 0, Last[randomPoints3U, 6], Join[{Last[randomPoints3U, 6 - Mod[(6 * (countQuestion + 1)), lengthUnique3]], First[randomPoints3U, Mod[(6 * (countQuestion + 1)), lengthUnique3]]}]) → uniqueRandomPoints3
  16. If(randomProb ≠ 2, ((42 + 2) * pixelHeightConvert), ((55 + 2) * pixelHeightConvert)) → titleHeight
  17. If(randomProb ≟ 2, 20, 100) → numMax
  18. If(randomProb ≟ 1, randomSlope1, randomProb ≟ 2, randomSlope2, 0) → randomSlope
  19. Zip((n, guideLine(n) + c / k), n, randomXH, c, randomMult, k, randomRecip) → problemPoints12
  20. Zip((round(x(n)), (round((y(n) * If[randomProb ≟ 2, 1, 0.2])) * If[randomProb ≟ 2, 1, 5])), n, problemPoints12) → problemPoints12Rounded
  21. Unique(KeepIf[y(n) < numMax, n, problemPoints12Rounded]) → problemPoints12U
  22. Length(problemPoints12U) → lengthUnique12
  23. If(6 < Mod[(6 * (countQuestion + 1)), lengthUnique12] < lengthUnique12, Take[problemPoints12U, Mod[(6 * countQuestion), lengthUnique12] + 1, Mod[(6 * (countQuestion + 1)), lengthUnique12]], Mod[(6 * (countQuestion + 1)), lengthUnique12] ≟ 0, Last[problemPoints12U, 6], Join[{Last[problemPoints12U, 6 - Mod[(6 * (countQuestion + 1)), lengthUnique12]], First[problemPoints12U, Mod[(6 * (countQuestion + 1)), lengthUnique12]]}]) → uniqueRandomPoints12
  24. If(randomProb ≟ 3, uniqueRandomPoints3, uniqueRandomPoints12) → randomPoints
  25. Sort(Zip[(round(x(n)), If[y(n) < 0, 0, y(n)]), n, randomPoints]) → randomPointsRounded
  26. If(randomProb ≟ 2, 0.2, 1) → scalingFactor
  27. Flatten(Sequence[Sequence[(n / 2, ((5 * m) * scalingFactor)), n, -6, 12], m, 0, 20]) → DragPoints
  28. Point(DragPoints) → InputPoint1
  29. Point(DragPoints) → InputPoint6
  30. Point(DragPoints) → InputPoint5
  31. Point(DragPoints) → InputPoint4
  32. Point(DragPoints) → InputPoint3
  33. Point(DragPoints) → InputPoint2
  34. Zip((x(n), y(n)), n, answerInput1) → answerInput
  35. KeepIf(¬(n ∈ answerInput), n, randomPointsRounded) → errorList
  36. Polygon({(-2.5, (105 * scalingFactor)), (-2.5, (-1 * scalingFactor)), (6.5, (-1 * scalingFactor)), (6.5, (105 * scalingFactor))}) → DragArea
  37. Sort(answerInput) → answerInputSorted
  38. Zip(n ∈ randomPointsRounded, n, answerInput) → boolCorrects
  39. Zip(abs(y(m) - y(n)), m, answerInputSorted, n, randomPointsRounded) → solutionYDifferences
  40. Zip(abs(x(m) - x(n)), m, answerInputSorted, n, randomPointsRounded) → solutionXDifferences
  41. Zip(n ≟ 0 ∧ m ≤ (2 * scalingFactor), n, solutionXDifferences, m, solutionYDifferences) → boolCorrectPoints
  42. Polygon(graphDimPoints) → graphArea
  43. Shuffle(Sequence[Random[20, 100], n, 1, 100]) → randomList2, {63, 23, 32, 22, 54, 56, 94, 40, 28, 86, 28, 36, 100, 30, 71, 21, 72, 47, 52, 75, 49, 65, 75, 35, 88, 74, 82, 32, 53, 38, 30, 98, 38, 100, 39, 72, 85, 95, 94, 73, 84, 23, 62, 34, 23, 30, 80, 68, 41, 92, 60, 71, 25, 92, 71, 61, 99, 79, 87, 98, 55, 64, 64, 33, 85, 96, 20, 63, 64, 79, 23, 61, 41, 96, 76, 24, 41, 60, 96, 41, 84, 52, 95, 57, 69, 87, 50, 34, 99, 44, 22, 30, 78, 62, 47, 86, 67, 20, 26, 66}
  44. Element(randomList2, Mod[countQuestion, 15] + 1) → randomNum2
  45. Shuffle(Sequence[Random[1, 6], n, 1, 100]) → randomList1, {5, 2, 5, 5, 5, 4, 6, 5, 6, 6, 3, 2, 5, 6, 5, 5, 3, 6, 5, 2, 5, 3, 6, 1, 5, 6, 4, 3, 2, 5, 2, 1, 2, 4, 3, 4, 2, 5, 3, 2, 3, 4, 4, 3, 4, 3, 2, 5, 1, 5, 5, 5, 3, 1, 3, 2, 2, 4, 2, 5, 1, 3, 3, 4, 3, 6, 2, 3, 1, 2, 1, 4, 5, 5, 2, 1, 6, 5, 1, 4, 5, 1, 2, 6, 2, 4, 4, 4, 2, 3, 2, 3, 2, 1, 2, 5, 3, 4, 2, 1}
  46. Element(randomList1, Mod[countQuestion, 20] + 1) → randomNum1
  47. Polygon(Zip[PixelsToPoint[Corner[1], Corner[3], Corner[5], A], A, {(pixelsLeft, pixelsTop), (pixelsLeft, y(Corner[5]) - pixelsBottom), Corner[5] - (pixelsRight, pixelsBottom), (x(Corner[5]) - pixelsRight, pixelsTop)}]) → borderBox
  48. Corner(5) → layoutAppSize
  49. Flatten(Sequence[6 / Random[20, 100], n, 1, 100]) → scatterLines
  50. Shuffle(Sequence[Random[20, 30], n, 1, 100]) → randomInts, {22, 23, 29, 27, 24, 26, 29, 23, 29, 22, 30, 22, 25, 23, 22, 21, 24, 23, 28, 25, 20, 22, 23, 20, 21, 24, 21, 25, 21, 20, 22, 26, 29, 20, 26, 20, 21, 25, 27, 25, 23, 22, 25, 30, 30, 28, 23, 22, 23, 24, 20, 23, 26, 29, 22, 22, 21, 29, 23, 29, 26, 22, 20, 25, 22, 20, 25, 28, 20, 26, 24, 22, 23, 23, 30, 27, 22, 21, 27, 22, 29, 30, 30, 27, 22, 30, 23, 26, 20, 21, 29, 20, 22, 20, 26, 21, 23, 20, 20, 23}
  51. Segment((0, 0), (graphDims(3), 0)) → axisX
  52. Segment((0, 0), (0, graphDims(4))) → axisY
  53. Shuffle(Sequence[Random[1, 2], n, 1, 100]) → randomOrders, {1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 1, 2, 2, 2, 1, 1, 1, 2, 2, 1, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 1, 2}
  54. Element(randomOrders, Mod[countQuestion, 100] + 1) → randomOrder
  55. Distance(Corner[sizeLabelX, 1], Corner[sizeLabelX, 2]) → numLabelXW
  56. Distance(Corner[sizeLabelY, 1], Corner[sizeLabelY, 2]) → numLabelYW
  57. Join({{tableLabel(1) + "&" + (tableLabel(2)) + "\vphantom{\frac{a}{b}}\\\hline"}, Sequence["" + (x(randomPointsRounded(n))) + "&" + (y(randomPointsRounded(n))) + "\vphantom{\large{|}}\\\hline", n, 1, 6]}) → textListForTable
  58. Sum(textListForTable) → textForTable
  59. Polygon(Sequence[Corner[textLabelX, n], n, 1, 4]) → boxAxisXLabel
  60. Polygon(Sequence[Corner[textLabelY, n], n, 1, 4]) → boxAxisYLabel
  61. Polygon(polygonCoords) → dragArea
  62. Corner(sizingText, 4) → CornerSizing
  63. Sequence(Corner[textLabelX, n], n, 1, 4) → xLabelCorners
  64. Sequence(Corner[textLabelY, n], n, 1, 4) → yLabelCorners
  65. VerticalText(textLabelY) → vertLabelY
  66. VerticalText(textLabelY) → sizeLabelYVert
  67. Distance(Corner[sizeLabelYVert, 1], Corner[sizeLabelYVert, 4]) → numVertYH
  68. Translate(PolygonCoordsStart, Vector[(2 * Vector[CornerSizing, PolygonCoordsStart])]) → StartInputPoint
  69. RemoveUndefined(Sequence[If[boolCorrectPoints(n), answerInputSorted(n)], n, 1, 6]) → correctPoints
  70. makeBox(CornerLeftTable, rowWidth, boxHeight) → hintBox
  71. If(animationSlider < 0.3, 0, animationSlider - 0.3) → animationSlider1
  72. PartitionPoint(HintPoint1, HintPoint3, animationSlider1, 1) → HintAnimate1
  73. PartitionPoint(HintPoint2, HintPoint3, animationSlider1, 1) → HintAnimate2
  74. Segment(HintPoint2, HintAnimate2 - (0.15, 0)) → hintSeg2
  75. Segment(HintPoint1, HintAnimate1 - (0, (2.4 * scalingFactor))) → hintSeg1
  76. Translate(hintBox, Vector[(0, ((-numFirstIncorrect) * rowHeight) - titleHeight)]) → hintBoxFirst
  77. Translate(hintBox, Vector[(0, ((-numFirstIncorrect) * rowHeight) - titleHeight)]) → hintBoxOutline
  78. Remove(answerInput, randomPointsRounded) → errorListInput
  79. Intersection(answerInput, randomPointsRounded) → solutionList
  80. Zip(PartitionPoint[n, m, animationSlider2, 1], n, Sort[errorListInput], m, Sort[errorList]) → solutionAnimation
  81. Sum({tableLabel(1) + "&" + (tableLabel(2)) + "\vphantom{\frac{a}{b}}\\\hline"}) → textForTitle
  82. Sum({"" + (x(randomPointsRounded(1))) + "&" + (y(randomPointsRounded(1))) + "\vphantom{\large{|}}\\\hline"}) → textForRow
  83. expandCircle(InputPoint1, 7 + (7 * pulsing), Corner[1], Corner[3], Corner[5]) → pulsingObject

AI 绘图提示语参考

该图形由一组随机生成的散点构成,点的坐标通过随机数生成并去重后排序。散点分布在坐标平面上,部分点可能被标记为特殊点。图形中包含一个矩形区域,用于表示可拖动的数据范围,以及一个边框框住整个散点区域。整体设计用于统计与概率教学,展示随机点分布和数据可视化效果。
以上提示语为根据原始绘图命令整理而来,仅供参考。