polar-angular-axis.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright 2023 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. # -----------------------------------------------------------------------------------------
  12. # To execute this script, make sure that the taipy-gui package is installed in your
  13. # Python environment and run:
  14. # python <script>
  15. # -----------------------------------------------------------------------------------------
  16. from taipy.gui import Gui
  17. # Create a star shape
  18. data = {"r": [3, 1] * 5 + [3], "theta": list(range(0, 360, 36)) + [0]}
  19. options = [
  20. # First plot is filled with a yellow-ish color
  21. {"subplot": "polar", "fill": "toself", "fillcolor": "#E4FF87"},
  22. # Second plot is filled with a blue-ish color
  23. {"fill": "toself", "subplot": "polar2", "fillcolor": "#709BFF"},
  24. ]
  25. layout = {
  26. "polar": {
  27. # This actually is the default value
  28. "angularaxis": {
  29. "direction": "counterclockwise",
  30. },
  31. },
  32. "polar2": {
  33. "angularaxis": {
  34. # Rotate the axis 180° (0 is on the left)
  35. "rotation": 180,
  36. # Orient the axis clockwise
  37. "direction": "clockwise",
  38. # Show the angles as radians
  39. "thetaunit": "radians",
  40. },
  41. },
  42. # Hide the legend
  43. "showlegend": False,
  44. }
  45. page = """
  46. # Polar Charts - Direction
  47. <|{data}|chart|type=scatterpolar|layout={layout}|options={options}|>
  48. """
  49. Gui(page).run()