scatter-more-styling.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. data = [
  19. {
  20. "x": [1, 2, 3, 4],
  21. "y": [10, 11, 12, 13],
  22. },
  23. {
  24. "x": [1, 2, 3, 4],
  25. "y": [11, 12, 13, 14],
  26. },
  27. {
  28. "x": [1, 2, 3, 4],
  29. "y": [12, 13, 14, 15],
  30. },
  31. ]
  32. options = [
  33. # First data set is represented by increasingly large
  34. # disks, getting more and more opaque
  35. {"marker": {"color": "red", "size": [12, 22, 32, 42], "opacity": [0.2, 0.5, 0.7, 1]}},
  36. # Second data set is represented with a different symbol
  37. # for each data point
  38. {
  39. "marker": {"color": "blue", "size": 18, "symbol": ["circle", "square", "diamond", "cross"]},
  40. },
  41. # Third data set is represented with green disks surrounded
  42. # by a red circle that becomes thicker and thicker
  43. {
  44. "marker": {"color": "green", "size": 20, "line": {"color": "red", "width": [2, 4, 6, 8]}},
  45. },
  46. ]
  47. markers = [
  48. # First data set is represented by increasingly large
  49. # disks, getting more and more opaque
  50. {"color": "red", "size": [12, 22, 32, 42], "opacity": [0.2, 0.5, 0.7, 1]},
  51. # Second data set is represented with a different symbol
  52. # for each data point
  53. {"color": "blue", "size": 18, "symbol": ["circle", "square", "diamond", "cross"]},
  54. # Third data set is represented with green disks surrounded
  55. # by a red circle that becomes thicker and thicker
  56. {"color": "green", "size": 20, "line": {"color": "red", "width": [2, 4, 6, 8]}},
  57. ]
  58. layout = {
  59. # Hide the chart legend
  60. "showlegend": False,
  61. # Remove all ticks from the x axis
  62. "xaxis": {"showticklabels": False},
  63. # Remove all ticks from the y axis
  64. "yaxis": {"showticklabels": False},
  65. }
  66. page = """
  67. ## Scatter - Customize markers
  68. <|{data}|chart|mode=markers|layout={layout}|marker={markers}|>
  69. """
  70. Gui(page).run()