条形图

条形图
几何画板及绘图内容加载中,请稍等……
2017-12-14 15:11
这个范例演示了条形图的绘制方法。它涉及条形图的基本概念,如分类数据、频率和相对频率。通过使用GeoGebra命令如Join、Sequence、BarChart等,可以动态地展示数据的变化。适合初中及以上学生学习数据统计与图表绘制。

GeoGebra 命令及参数

  1. Join({{0}, Sort[First[Shuffle[Sequence[20]], catCount]]}) → positions
  2. Sequence(Element[positions, i] - Element[positions, i - 1], i, 2, catCount + 1) → counts
  3. RandomElement({"pet", "sport", "fruit", "food", "subject"}) → category
  4. RandomElement({"H", "V"}) → HV
  5. Sequence(Polygon[(0, i - 1 / 4), (counts(i), i - 1 / 4), (counts(i), i + 1 / 4), (0, i + 1 / 4)], i, 1, catCount) → L_1
  6. If(HV ≟ "V", catCount + 1, Max[counts] + 1) → xmax
  7. If(HV ≟ "H", catCount + 1, Max[counts] + 1) → ymax
  8. Shuffle(First[If[category ≟ "fruit", {"apples", "oranges", "bananas", "grapes"}, If[category ≟ "pet", {"cats", "dogs", "fish", "rabbits"}, If[category ≟ "sport", {"baseball", "basketball", "football", "soccer"}, If[category ≟ "food", {"pizza", "chicken", "steak", "hot dogs"}, If[category ≟ "subject", {"math", "reading", "writing", "science"}]]]]], catCount]) → labels
  9. If(HV ≟ "H", (-1 / 3 * xmax), -1 / 2) → xmin
  10. If(HV ≟ "V", (-1 / 4 * ymax), -1 / 2) → ymin
  11. BarChart(labels, counts, 1 / 2) → a
  12. Segment((0, 0), (xmax + 1, 0)) → xaxis
  13. Segment((0, 0), (0, ymax + 1)) → yaxis
  14. If(HV ≟ "V", Sequence[Ray[(0, i), (1, i)], i, 1, ymax + 1], Sequence[Ray[(i, 0), (i, 1)], i, 1, xmax + 1]) → lines
  15. Sum(counts) → sum
  16. Textfield(totalText) → InputBox1
  17. RandomElement(labels) → choice21
  18. RandomElement(Remove[labels, {choice21}]) → choice22
  19. If(Element[counts, IndexOf[choice21, labels]] > Element[counts, IndexOf[choice22, labels]], choice21, If[Element[counts, IndexOf[choice21, labels]] < Element[counts, IndexOf[choice22, labels]], choice22, "same"]) → answer2
  20. If(HV ≟ "H", Sequence[Point[{xmin / 1.1, i}], i, 1, catCount], Sequence[Point[{i - 1 / 3, ((-ymax)) / 10}], i, 1, catCount]) → anchors
  21. Zip(Text[AA, BB], AA, labels, BB, anchors) → L_2
  22. RandomElement(labels) → choice31
  23. RandomElement(Remove[labels, {choice31}]) → choice32
  24. RandomElement({"more", "fewer"}) → moreOrFewer
  25. If(Element[counts, IndexOf[choice31, labels]] < Element[counts, IndexOf[choice32, labels]], {{choice31, Element[counts, IndexOf[choice31, labels]]}, {choice32, Element[counts, IndexOf[choice32, labels]]}}, {{choice32, Element[counts, IndexOf[choice32, labels]]}, {choice31, Element[counts, IndexOf[choice31, labels]]}}) → threeHelper
  26. Textfield(threeText) → InputBox3
  27. Textfield(fourText) → InputBox4
  28. Shuffle(Zip[{AA, BB}, AA, labels, BB, counts]) → fourList
  29. If(HV ≟ "H", Sequence[Text[i, (i - xmax / 55, (ymin) / 1.5)], i, 1, xmax], Sequence[Text[i, (xmin / 1.3, i - ymax / 50)], i, 1, ymax]) → numbers

AI 绘图提示语参考

绘制一个条形图,展示不同类别的数据频率。首先,生成多个类别标签,如宠物、运动、水果等,并为每个类别随机分配数量。然后,根据数量绘制条形,条形高度与数量成正比。最后,添加坐标轴和网格线,使图表更清晰。
以上提示语为根据原始绘图命令整理而来,仅供参考。