1
0

advanced-python-lib.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # 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(go.Violin(name="Normal",
  26. y=np.random.normal(loc=0, scale=1, size=1000),
  27. box_visible=True, meanline_visible=True))
  28. # Add trace for Exponential Distribution
  29. figure.add_trace(go.Violin(name="Exponential",
  30. y=np.random.exponential(scale=1, size=1000),
  31. box_visible=True, meanline_visible=True))
  32. # Add trace for Uniform Distribution
  33. figure.add_trace(go.Violin(name="Uniform",
  34. y=np.random.uniform(low=0, high=1, size=1000),
  35. box_visible=True, meanline_visible=True))
  36. # Updating layout for better visualization
  37. figure.update_layout(title="Different Probability Distributions")
  38. page = """
  39. # Plotly Python
  40. <|toggle|theme|>
  41. <|chart|figure={figure}|>
  42. """
  43. Gui(page).run()