polar-angular-axis.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright 2021-2024 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. if __name__ == "__main__":
  18. # Create a star shape
  19. data = {"r": [3, 1] * 5 + [3], "theta": list(range(0, 360, 36)) + [0]}
  20. options = [
  21. # First plot is filled with a yellow-ish color
  22. {"subplot": "polar", "fill": "toself", "fillcolor": "#E4FF87"},
  23. # Second plot is filled with a blue-ish color
  24. {"fill": "toself", "subplot": "polar2", "fillcolor": "#709BFF"},
  25. ]
  26. layout = {
  27. "polar": {
  28. # This actually is the default value
  29. "angularaxis": {
  30. "direction": "counterclockwise",
  31. },
  32. },
  33. "polar2": {
  34. "angularaxis": {
  35. # Rotate the axis 180° (0 is on the left)
  36. "rotation": 180,
  37. # Orient the axis clockwise
  38. "direction": "clockwise",
  39. # Show the angles as radians
  40. "thetaunit": "radians",
  41. },
  42. },
  43. # Hide the legend
  44. "showlegend": False,
  45. }
  46. page = """
  47. # Polar Charts - Direction
  48. <|{data}|chart|type=scatterpolar|layout={layout}|options={options}|>
  49. """
  50. Gui(page).run()