Bar Charts

Bar Charts
Loading the math board and drawing, please wait…
2017-12-14 23:11
This example demonstrates the creation of bar charts. It covers fundamental concepts such as categorical data, frequency, and relative frequency. Using GeoGebra commands like Join, Sequence, and BarChart, dynamic data visualization is achieved. Suitable for middle school and above students to learn data statistics and chart drawing.

GeoGebra Commands & Parameters

  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 Drawing Prompt Reference

Create a bar chart to display the frequency of data across different categories. Generate multiple category labels like pets, sports, fruits, etc., and assign random counts to each. Draw bars corresponding to each category, with the height of each bar proportional to its count. Add axes and grid lines for clarity.
The prompt above was compiled from the original drawing commands and is for reference only.