1
0

advanced_python_lib.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Copyright 2021-2025 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. # This script needs to run in a Python environment where the plotly-express package is
  17. # installed.
  18. # -----------------------------------------------------------------------------------------
  19. import numpy as np
  20. import plotly.graph_objects as go
  21. from taipy.gui import Gui
  22. # Create the Plotly figure object
  23. figure = go.Figure()
  24. # Add trace for Normal Distribution
  25. figure.add_trace(
  26. go.Violin(name="Normal", y=np.random.normal(loc=0, scale=1, size=1000), box_visible=True, meanline_visible=True)
  27. )
  28. # Add trace for Exponential Distribution
  29. figure.add_trace(
  30. go.Violin(name="Exponential", y=np.random.exponential(scale=1, size=1000), box_visible=True, meanline_visible=True)
  31. )
  32. # Add trace for Uniform Distribution
  33. figure.add_trace(
  34. go.Violin(name="Uniform", y=np.random.uniform(low=0, high=1, size=1000), box_visible=True, meanline_visible=True)
  35. )
  36. # Updating layout for better visualization
  37. figure.update_layout(title="Different Probability Distributions")
  38. page = """
  39. <|chart|figure={figure}|>
  40. """
  41. if __name__ == "__main__":
  42. Gui(page).run(title="Chart - Advanced - Python lib")