From e836adb1d92d95ec3e9799d70140a63ea76d27f4 Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 04:33:00 -0400
Subject: [PATCH 01/34] add matplotlib chart example
---
doc/gui/examples/charts/matplotlib_scatter.py | 73 +++++++++++++++++++
1 file changed, 73 insertions(+)
create mode 100644 doc/gui/examples/charts/matplotlib_scatter.py
diff --git a/doc/gui/examples/charts/matplotlib_scatter.py b/doc/gui/examples/charts/matplotlib_scatter.py
new file mode 100644
index 0000000000..5683b4cf21
--- /dev/null
+++ b/doc/gui/examples/charts/matplotlib_scatter.py
@@ -0,0 +1,73 @@
+from taipy.gui import Gui
+
+# Read the saved HTML chart
+with open("chart.html", "r") as f:
+ html_str = f.read()
+
+# Define the page content with the interactive chart
+page_md = f"""
+# Taipy Matplotlib Enhanced 2D Scatter Plot Page
+
+This page contains an enhanced 2D scatter plot created with Matplotlib:
+
+
+
+## Code
+
+The following Python code was used to generate the chart:
+
+```python
+import matplotlib.pyplot as plt
+import numpy as np
+import mpld3
+
+plt.style.use('_mpl-gallery')
+
+# Make the data
+np.random.seed(3)
+x = np.random.uniform(1, 6, 24) # Random x values within 1-6
+y = np.random.uniform(1, 6, 24) # Random y values within 1-6
+
+# Size and color
+sizes = np.random.uniform(300, 800, len(x)) # Adjusted sizes for better fit
+colors = np.random.uniform(50, 100, len(x)) # Greenish colors
+
+# Plot
+fig, ax = plt.subplots(figsize=(10, 6))
+scatter = ax.scatter(x, y, s=sizes, c=colors, cmap="Greens", vmin=30, vmax=80)
+ax.set(xlim=(1, 6), xticks=np.arange(1, 7), ylim=(1, 6), yticks=np.arange(1, 7))
+
+# Add axis labels
+ax.set_xlabel('Performance Score')
+ax.set_ylabel('Happiness Index')
+ax.set_title('Employee Performance vs. Happiness')
+
+# Example labels for bubbles
+for i in range(len(x)):
+ ax.text(x[i], y[i], f'Employee {i+1}', fontsize=9, ha='right')
+
+# Create legend for bubble sizes
+legend_labels = np.unique(np.round(sizes, decimals=-1))
+for label in legend_labels:
+ ax.scatter([], [], c='g', alpha=0.5, s=label, label=str(int(label)))
+
+legend1 = ax.legend(title="Bubble Size (Efficiency)", loc="upper right", frameon=True, fontsize=10)
+ax.legend(title="Bubble Size (Efficiency)", scatterpoints=1, labelspacing=1.5)
+ax.add_artist(legend1)
+
+# Convert the plot to an interactive HTML
+html_str = mpld3.fig_to_html(fig)
+
+# Save the HTML to a file
+with open("chart.html", "w") as f:
+ f.write(html_str)
+
+# Show the plot in a browser
+mpld3.show()
+\```
+
+\```
+
+Gui(page_md).run()
From 7c7c237a732906b76217b828d134feb209d39cdd Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 04:33:22 -0400
Subject: [PATCH 02/34] add matplotlib taipy chart example
---
doc/gui/examples/charts/matplotlib_chart.py | 47 +++++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 doc/gui/examples/charts/matplotlib_chart.py
diff --git a/doc/gui/examples/charts/matplotlib_chart.py b/doc/gui/examples/charts/matplotlib_chart.py
new file mode 100644
index 0000000000..75d5dd52d3
--- /dev/null
+++ b/doc/gui/examples/charts/matplotlib_chart.py
@@ -0,0 +1,47 @@
+import matplotlib.pyplot as plt
+import numpy as np
+import mpld3
+
+plt.style.use('_mpl-gallery')
+
+# Make the data
+np.random.seed(3)
+x = np.random.uniform(1, 6, 10) # Random x values within 1-6
+y = np.random.uniform(1, 6, 10) # Random y values within 1-6
+
+# Size and color
+sizes = np.random.uniform(300, 600, len(x)) # Adjusted sizes for better fit
+colors = np.random.uniform(50, 100, len(x)) # Greenish colors
+
+# Plot
+fig, ax = plt.subplots(figsize=(10, 6))
+scatter = ax.scatter(x, y, s=sizes, c=colors, cmap="Greens", vmin=30, vmax=80)
+ax.set(xlim=(1, 6), xticks=np.arange(1, 7), ylim=(1, 6), yticks=np.arange(1, 7))
+
+# Add axis labels
+ax.set_xlabel('Performance Score')
+ax.set_ylabel('Happiness Index')
+ax.set_title('Employee Performance vs. Happiness')
+
+# Example labels for bubbles
+for i in range(len(x)):
+ ax.text(x[i], y[i], f'Employee {i+1}', fontsize=16, ha='right')
+
+# Create legend for bubble sizes
+legend_labels = np.unique(np.round(sizes, decimals=-1))
+for label in legend_labels:
+ ax.scatter([], [], c='g', alpha=0.5, s=label, label=str(int(label)))
+
+legend1 = ax.legend(title="Bubble Size (Efficiency)", loc="upper right", frameon=True, fontsize=10)
+ax.legend(title="Bubble Size (Efficiency)", scatterpoints=1, labelspacing=1.5)
+ax.add_artist(legend1)
+
+# Convert the plot to an interactive HTML
+html_str = mpld3.fig_to_html(fig)
+
+# Save the HTML to a file
+with open("chart.html", "w") as f:
+ f.write(html_str)
+
+# Show the plot in a browser
+mpld3.show()
From 40ac40ee3c945db72e096fd71c0651e901d14c65 Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 15:08:49 -0400
Subject: [PATCH 03/34] add matplotlib scatter md py
---
doc/gui/examples/charts/matplotlib_scatter.py | 63 +++++++------------
1 file changed, 21 insertions(+), 42 deletions(-)
diff --git a/doc/gui/examples/charts/matplotlib_scatter.py b/doc/gui/examples/charts/matplotlib_scatter.py
index 5683b4cf21..326485815e 100644
--- a/doc/gui/examples/charts/matplotlib_scatter.py
+++ b/doc/gui/examples/charts/matplotlib_scatter.py
@@ -1,52 +1,29 @@
from taipy.gui import Gui
-
-# Read the saved HTML chart
-with open("chart.html", "r") as f:
- html_str = f.read()
-
-# Define the page content with the interactive chart
-page_md = f"""
-# Taipy Matplotlib Enhanced 2D Scatter Plot Page
-
-This page contains an enhanced 2D scatter plot created with Matplotlib:
-
-
-
-## Code
-
-The following Python code was used to generate the chart:
-
-```python
import matplotlib.pyplot as plt
-import numpy as np
import mpld3
+import numpy as np # Import numpy
-plt.style.use('_mpl-gallery')
-
-# Make the data
-np.random.seed(3)
-x = np.random.uniform(1, 6, 24) # Random x values within 1-6
-y = np.random.uniform(1, 6, 24) # Random y values within 1-6
+# Define data
+employee_performance = [5, 4.8, 4.5, 4.2, 3.9, 3.7, 4.1, 4.6, 5.0, 4.3]
+happiness_scores = [5, 4.5, 4.2, 4.0, 3.8, 3.9, 4.3, 4.7, 4.9, 4.4]
-# Size and color
-sizes = np.random.uniform(300, 800, len(x)) # Adjusted sizes for better fit
-colors = np.random.uniform(50, 100, len(x)) # Greenish colors
+# Calculate sizes based on product of performance and happiness
+sizes = [e * h * 50 for e, h in zip(employee_performance, happiness_scores)]
+colors = sizes # Color based on sizes
# Plot
fig, ax = plt.subplots(figsize=(10, 6))
-scatter = ax.scatter(x, y, s=sizes, c=colors, cmap="Greens", vmin=30, vmax=80)
+scatter = ax.scatter(employee_performance, happiness_scores, s=sizes, c=colors, cmap="Greens", vmin=min(colors), vmax=max(colors))
ax.set(xlim=(1, 6), xticks=np.arange(1, 7), ylim=(1, 6), yticks=np.arange(1, 7))
-# Add axis labels
+# Add axis labels and title
ax.set_xlabel('Performance Score')
ax.set_ylabel('Happiness Index')
ax.set_title('Employee Performance vs. Happiness')
# Example labels for bubbles
-for i in range(len(x)):
- ax.text(x[i], y[i], f'Employee {i+1}', fontsize=9, ha='right')
+for i in range(len(employee_performance)):
+ ax.text(employee_performance[i], happiness_scores[i], f'Emp {i+1}', fontsize=9, ha='right')
# Create legend for bubble sizes
legend_labels = np.unique(np.round(sizes, decimals=-1))
@@ -60,14 +37,16 @@
# Convert the plot to an interactive HTML
html_str = mpld3.fig_to_html(fig)
-# Save the HTML to a file
-with open("chart.html", "w") as f:
- f.write(html_str)
+# Define Taipy page content
+page_md = f"""
+# Enhanced 2D Scatter Plot
-# Show the plot in a browser
-mpld3.show()
-\```
+This page contains an enhanced 2D scatter plot created with Matplotlib:
-\```
+
+"""
-Gui(page_md).run()
+if __name__ == "__main__":
+ Gui(page_md).run(title="Chart Scatter Matplotlib")
From f5c15ab0dd2edd9df7e12d79b5ef2cc33b0e0b22 Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 15:40:04 -0400
Subject: [PATCH 04/34] update matplotlib scatter md
---
doc/gui/examples/charts/matplotlib_scatter.py | 31 ++++++++++---------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/doc/gui/examples/charts/matplotlib_scatter.py b/doc/gui/examples/charts/matplotlib_scatter.py
index 326485815e..7fa9519de2 100644
--- a/doc/gui/examples/charts/matplotlib_scatter.py
+++ b/doc/gui/examples/charts/matplotlib_scatter.py
@@ -1,7 +1,8 @@
from taipy.gui import Gui
+import matplotlib
+matplotlib.use('Agg') # Use a non-interactive backend
import matplotlib.pyplot as plt
-import mpld3
-import numpy as np # Import numpy
+import numpy as np
# Define data
employee_performance = [5, 4.8, 4.5, 4.2, 3.9, 3.7, 4.1, 4.6, 5.0, 4.3]
@@ -25,27 +26,27 @@
for i in range(len(employee_performance)):
ax.text(employee_performance[i], happiness_scores[i], f'Emp {i+1}', fontsize=9, ha='right')
-# Create legend for bubble sizes
-legend_labels = np.unique(np.round(sizes, decimals=-1))
-for label in legend_labels:
- ax.scatter([], [], c='g', alpha=0.5, s=label, label=str(int(label)))
-
-legend1 = ax.legend(title="Bubble Size (Efficiency)", loc="upper right", frameon=True, fontsize=10)
-ax.legend(title="Bubble Size (Efficiency)", scatterpoints=1, labelspacing=1.5)
-ax.add_artist(legend1)
-
# Convert the plot to an interactive HTML
html_str = mpld3.fig_to_html(fig)
+# Structure data for Taipy
+data = {
+ "x": employee_performance,
+ "y": happiness_scores,
+ "marker": {
+ "size": sizes,
+ "color": colors,
+ "colorscale": "Greens"
+ }
+}
+
# Define Taipy page content
-page_md = f"""
+page_md = """
# Enhanced 2D Scatter Plot
This page contains an enhanced 2D scatter plot created with Matplotlib:
-
+<|{data}|chart|mode=markers|x=x|y=y|marker={marker}|>
"""
if __name__ == "__main__":
From 8036a1e0c4a27ca52c310b048f37a1d6bdea6e64 Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 16:22:49 -0400
Subject: [PATCH 05/34] update matplotlib scatter py
---
doc/gui/examples/charts/matplotlib_scatter.py | 42 ++++++++++---------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/doc/gui/examples/charts/matplotlib_scatter.py b/doc/gui/examples/charts/matplotlib_scatter.py
index 7fa9519de2..7a41fb3e7a 100644
--- a/doc/gui/examples/charts/matplotlib_scatter.py
+++ b/doc/gui/examples/charts/matplotlib_scatter.py
@@ -1,8 +1,8 @@
from taipy.gui import Gui
import matplotlib
-matplotlib.use('Agg') # Use a non-interactive backend
import matplotlib.pyplot as plt
import numpy as np
+import mpld3
# Define data
employee_performance = [5, 4.8, 4.5, 4.2, 3.9, 3.7, 4.1, 4.6, 5.0, 4.3]
@@ -12,12 +12,10 @@
sizes = [e * h * 50 for e, h in zip(employee_performance, happiness_scores)]
colors = sizes # Color based on sizes
-# Plot
-fig, ax = plt.subplots(figsize=(10, 6))
+# Create the Matplotlib figure
+figure, ax = plt.subplots(figsize=(10, 6))
scatter = ax.scatter(employee_performance, happiness_scores, s=sizes, c=colors, cmap="Greens", vmin=min(colors), vmax=max(colors))
ax.set(xlim=(1, 6), xticks=np.arange(1, 7), ylim=(1, 6), yticks=np.arange(1, 7))
-
-# Add axis labels and title
ax.set_xlabel('Performance Score')
ax.set_ylabel('Happiness Index')
ax.set_title('Employee Performance vs. Happiness')
@@ -26,28 +24,32 @@
for i in range(len(employee_performance)):
ax.text(employee_performance[i], happiness_scores[i], f'Emp {i+1}', fontsize=9, ha='right')
+# Create legend for bubble sizes
+legend_labels = np.unique(np.round(sizes, decimals=-1))
+for label in legend_labels:
+ ax.scatter([], [], c='g', alpha=0.5, s=label, label=str(int(label)))
+
+legend1 = ax.legend(title="Bubble Size (Efficiency)", loc="upper right", frameon=True, fontsize=10)
+ax.legend(title="Bubble Size (Efficiency)", scatterpoints=1, labelspacing=1.5)
+ax.add_artist(legend1)
+
+# Ensure figure is rendered in Taipy
+figure.tight_layout()
+
# Convert the plot to an interactive HTML
-html_str = mpld3.fig_to_html(fig)
-
-# Structure data for Taipy
-data = {
- "x": employee_performance,
- "y": happiness_scores,
- "marker": {
- "size": sizes,
- "color": colors,
- "colorscale": "Greens"
- }
-}
+#html_str = mpld3.fig_to_html(figure)
+
+# Show the plot in a browser
+#mpld3.show()
# Define Taipy page content
-page_md = """
+page = f"""
# Enhanced 2D Scatter Plot
This page contains an enhanced 2D scatter plot created with Matplotlib:
-<|{data}|chart|mode=markers|x=x|y=y|marker={marker}|>
+<|data={figure}|chart|height=520px|>
"""
if __name__ == "__main__":
- Gui(page_md).run(title="Chart Scatter Matplotlib")
+ Gui(page).run(title="Chart Scatter Matplotlib")
From 62de9a17b424240d020a3c715477e73afc010bd9 Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 17:12:46 -0400
Subject: [PATCH 06/34] update matplotlib scatter
---
doc/gui/examples/charts/matplotlib_scatter.py | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/doc/gui/examples/charts/matplotlib_scatter.py b/doc/gui/examples/charts/matplotlib_scatter.py
index 7a41fb3e7a..de2e48a784 100644
--- a/doc/gui/examples/charts/matplotlib_scatter.py
+++ b/doc/gui/examples/charts/matplotlib_scatter.py
@@ -1,5 +1,4 @@
from taipy.gui import Gui
-import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import mpld3
@@ -13,7 +12,7 @@
colors = sizes # Color based on sizes
# Create the Matplotlib figure
-figure, ax = plt.subplots(figsize=(10, 6))
+fig, ax = plt.subplots(figsize=(12, 8)) # Adjust figsize for better height
scatter = ax.scatter(employee_performance, happiness_scores, s=sizes, c=colors, cmap="Greens", vmin=min(colors), vmax=max(colors))
ax.set(xlim=(1, 6), xticks=np.arange(1, 7), ylim=(1, 6), yticks=np.arange(1, 7))
ax.set_xlabel('Performance Score')
@@ -29,26 +28,20 @@
for label in legend_labels:
ax.scatter([], [], c='g', alpha=0.5, s=label, label=str(int(label)))
-legend1 = ax.legend(title="Bubble Size (Efficiency)", loc="upper right", frameon=True, fontsize=10)
-ax.legend(title="Bubble Size (Efficiency)", scatterpoints=1, labelspacing=1.5)
+# Only one legend on the left side
+legend1 = ax.legend(title="Bubble Size (Efficiency)", loc="upper left", frameon=True, fontsize=10)
ax.add_artist(legend1)
-# Ensure figure is rendered in Taipy
-figure.tight_layout()
-
# Convert the plot to an interactive HTML
-#html_str = mpld3.fig_to_html(figure)
-
-# Show the plot in a browser
-#mpld3.show()
+html_str = mpld3.fig_to_html(fig)
# Define Taipy page content
-page = f"""
+page = """
# Enhanced 2D Scatter Plot
This page contains an enhanced 2D scatter plot created with Matplotlib:
-<|data={figure}|chart|height=520px|>
+<|part|content={fig}|height=600px>
"""
if __name__ == "__main__":
From 6b923225b060c59788b816cd90270c3dba0c8e6d Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 17:13:52 -0400
Subject: [PATCH 07/34] update matplotlib scatter
---
doc/gui/examples/charts/matplotlib_scatter.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/gui/examples/charts/matplotlib_scatter.py b/doc/gui/examples/charts/matplotlib_scatter.py
index de2e48a784..48a1834d2a 100644
--- a/doc/gui/examples/charts/matplotlib_scatter.py
+++ b/doc/gui/examples/charts/matplotlib_scatter.py
@@ -33,7 +33,7 @@
ax.add_artist(legend1)
# Convert the plot to an interactive HTML
-html_str = mpld3.fig_to_html(fig)
+# html_str = mpld3.fig_to_html(fig)
# Define Taipy page content
page = """
From 117e2008782a9b8942a6f6af26e370339a0ce595 Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 18:45:51 -0400
Subject: [PATCH 08/34] move to matplotlib folder
---
doc/gui/examples/charts/matplotlib_chart.py | 47 ------------------
doc/gui/examples/charts/matplotlib_scatter.py | 48 -------------------
2 files changed, 95 deletions(-)
delete mode 100644 doc/gui/examples/charts/matplotlib_chart.py
delete mode 100644 doc/gui/examples/charts/matplotlib_scatter.py
diff --git a/doc/gui/examples/charts/matplotlib_chart.py b/doc/gui/examples/charts/matplotlib_chart.py
deleted file mode 100644
index 75d5dd52d3..0000000000
--- a/doc/gui/examples/charts/matplotlib_chart.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import matplotlib.pyplot as plt
-import numpy as np
-import mpld3
-
-plt.style.use('_mpl-gallery')
-
-# Make the data
-np.random.seed(3)
-x = np.random.uniform(1, 6, 10) # Random x values within 1-6
-y = np.random.uniform(1, 6, 10) # Random y values within 1-6
-
-# Size and color
-sizes = np.random.uniform(300, 600, len(x)) # Adjusted sizes for better fit
-colors = np.random.uniform(50, 100, len(x)) # Greenish colors
-
-# Plot
-fig, ax = plt.subplots(figsize=(10, 6))
-scatter = ax.scatter(x, y, s=sizes, c=colors, cmap="Greens", vmin=30, vmax=80)
-ax.set(xlim=(1, 6), xticks=np.arange(1, 7), ylim=(1, 6), yticks=np.arange(1, 7))
-
-# Add axis labels
-ax.set_xlabel('Performance Score')
-ax.set_ylabel('Happiness Index')
-ax.set_title('Employee Performance vs. Happiness')
-
-# Example labels for bubbles
-for i in range(len(x)):
- ax.text(x[i], y[i], f'Employee {i+1}', fontsize=16, ha='right')
-
-# Create legend for bubble sizes
-legend_labels = np.unique(np.round(sizes, decimals=-1))
-for label in legend_labels:
- ax.scatter([], [], c='g', alpha=0.5, s=label, label=str(int(label)))
-
-legend1 = ax.legend(title="Bubble Size (Efficiency)", loc="upper right", frameon=True, fontsize=10)
-ax.legend(title="Bubble Size (Efficiency)", scatterpoints=1, labelspacing=1.5)
-ax.add_artist(legend1)
-
-# Convert the plot to an interactive HTML
-html_str = mpld3.fig_to_html(fig)
-
-# Save the HTML to a file
-with open("chart.html", "w") as f:
- f.write(html_str)
-
-# Show the plot in a browser
-mpld3.show()
diff --git a/doc/gui/examples/charts/matplotlib_scatter.py b/doc/gui/examples/charts/matplotlib_scatter.py
deleted file mode 100644
index 48a1834d2a..0000000000
--- a/doc/gui/examples/charts/matplotlib_scatter.py
+++ /dev/null
@@ -1,48 +0,0 @@
-from taipy.gui import Gui
-import matplotlib.pyplot as plt
-import numpy as np
-import mpld3
-
-# Define data
-employee_performance = [5, 4.8, 4.5, 4.2, 3.9, 3.7, 4.1, 4.6, 5.0, 4.3]
-happiness_scores = [5, 4.5, 4.2, 4.0, 3.8, 3.9, 4.3, 4.7, 4.9, 4.4]
-
-# Calculate sizes based on product of performance and happiness
-sizes = [e * h * 50 for e, h in zip(employee_performance, happiness_scores)]
-colors = sizes # Color based on sizes
-
-# Create the Matplotlib figure
-fig, ax = plt.subplots(figsize=(12, 8)) # Adjust figsize for better height
-scatter = ax.scatter(employee_performance, happiness_scores, s=sizes, c=colors, cmap="Greens", vmin=min(colors), vmax=max(colors))
-ax.set(xlim=(1, 6), xticks=np.arange(1, 7), ylim=(1, 6), yticks=np.arange(1, 7))
-ax.set_xlabel('Performance Score')
-ax.set_ylabel('Happiness Index')
-ax.set_title('Employee Performance vs. Happiness')
-
-# Example labels for bubbles
-for i in range(len(employee_performance)):
- ax.text(employee_performance[i], happiness_scores[i], f'Emp {i+1}', fontsize=9, ha='right')
-
-# Create legend for bubble sizes
-legend_labels = np.unique(np.round(sizes, decimals=-1))
-for label in legend_labels:
- ax.scatter([], [], c='g', alpha=0.5, s=label, label=str(int(label)))
-
-# Only one legend on the left side
-legend1 = ax.legend(title="Bubble Size (Efficiency)", loc="upper left", frameon=True, fontsize=10)
-ax.add_artist(legend1)
-
-# Convert the plot to an interactive HTML
-# html_str = mpld3.fig_to_html(fig)
-
-# Define Taipy page content
-page = """
-# Enhanced 2D Scatter Plot
-
-This page contains an enhanced 2D scatter plot created with Matplotlib:
-
-<|part|content={fig}|height=600px>
-"""
-
-if __name__ == "__main__":
- Gui(page).run(title="Chart Scatter Matplotlib")
From 4d68408ee30980580c3604deb91e1993aa23e7bb Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 18:46:03 -0400
Subject: [PATCH 09/34] add custom css
---
doc/gui/examples/charts/matplotlib/styles.css | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 doc/gui/examples/charts/matplotlib/styles.css
diff --git a/doc/gui/examples/charts/matplotlib/styles.css b/doc/gui/examples/charts/matplotlib/styles.css
new file mode 100644
index 0000000000..d6e5161f60
--- /dev/null
+++ b/doc/gui/examples/charts/matplotlib/styles.css
@@ -0,0 +1,14 @@
+div.taipy-part.MuiBox-root {
+ height: 560px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+img{
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ max-height: 100%;
+ max-width: 100%;
+}
From 911a802d8f7884ddc49abe2e405d558561814f2e Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 18:46:29 -0400
Subject: [PATCH 10/34] moved matplotlib example files
---
.../charts/matplotlib/matplotlib_chart.py | 47 ++++++++++++++++
.../charts/matplotlib/matplotlib_scatter.py | 53 +++++++++++++++++++
2 files changed, 100 insertions(+)
create mode 100644 doc/gui/examples/charts/matplotlib/matplotlib_chart.py
create mode 100644 doc/gui/examples/charts/matplotlib/matplotlib_scatter.py
diff --git a/doc/gui/examples/charts/matplotlib/matplotlib_chart.py b/doc/gui/examples/charts/matplotlib/matplotlib_chart.py
new file mode 100644
index 0000000000..75d5dd52d3
--- /dev/null
+++ b/doc/gui/examples/charts/matplotlib/matplotlib_chart.py
@@ -0,0 +1,47 @@
+import matplotlib.pyplot as plt
+import numpy as np
+import mpld3
+
+plt.style.use('_mpl-gallery')
+
+# Make the data
+np.random.seed(3)
+x = np.random.uniform(1, 6, 10) # Random x values within 1-6
+y = np.random.uniform(1, 6, 10) # Random y values within 1-6
+
+# Size and color
+sizes = np.random.uniform(300, 600, len(x)) # Adjusted sizes for better fit
+colors = np.random.uniform(50, 100, len(x)) # Greenish colors
+
+# Plot
+fig, ax = plt.subplots(figsize=(10, 6))
+scatter = ax.scatter(x, y, s=sizes, c=colors, cmap="Greens", vmin=30, vmax=80)
+ax.set(xlim=(1, 6), xticks=np.arange(1, 7), ylim=(1, 6), yticks=np.arange(1, 7))
+
+# Add axis labels
+ax.set_xlabel('Performance Score')
+ax.set_ylabel('Happiness Index')
+ax.set_title('Employee Performance vs. Happiness')
+
+# Example labels for bubbles
+for i in range(len(x)):
+ ax.text(x[i], y[i], f'Employee {i+1}', fontsize=16, ha='right')
+
+# Create legend for bubble sizes
+legend_labels = np.unique(np.round(sizes, decimals=-1))
+for label in legend_labels:
+ ax.scatter([], [], c='g', alpha=0.5, s=label, label=str(int(label)))
+
+legend1 = ax.legend(title="Bubble Size (Efficiency)", loc="upper right", frameon=True, fontsize=10)
+ax.legend(title="Bubble Size (Efficiency)", scatterpoints=1, labelspacing=1.5)
+ax.add_artist(legend1)
+
+# Convert the plot to an interactive HTML
+html_str = mpld3.fig_to_html(fig)
+
+# Save the HTML to a file
+with open("chart.html", "w") as f:
+ f.write(html_str)
+
+# Show the plot in a browser
+mpld3.show()
diff --git a/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py b/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py
new file mode 100644
index 0000000000..bfcdd78fd8
--- /dev/null
+++ b/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py
@@ -0,0 +1,53 @@
+from taipy.gui import Gui
+import matplotlib.pyplot as plt
+import numpy as np
+import mpld3
+
+from taipy.gui import Gui
+import matplotlib.pyplot as plt
+import numpy as np
+import mpld3
+
+# Define data
+employee_performance = [5, 4.8, 4.5, 4.2, 3.9, 3.7, 4.1, 4.6, 5.0, 4.3]
+happiness_scores = [5, 4.5, 4.2, 4.0, 3.8, 3.9, 4.3, 4.7, 4.9, 4.4]
+
+# Calculate sizes based on product of performance and happiness, scaled to 1-100%
+sizes = [e * h * 20 for e, h in zip(employee_performance, happiness_scores)]
+colors = sizes # Color based on sizes
+
+# Create the Matplotlib figure
+fig, ax = plt.subplots(figsize=(12, 5.2)) # Adjust figsize for a slightly smaller chart
+scatter = ax.scatter(employee_performance, happiness_scores, s=sizes, c=colors, cmap="Greens", vmin=min(colors), vmax=max(colors))
+ax.set(xlim=(1, 6), xticks=np.arange(1, 7), ylim=(1, 6), yticks=np.arange(1, 7))
+ax.set_xlabel('Performance Score')
+ax.set_ylabel('Happiness Index')
+ax.set_title('Employee Performance vs. Happiness')
+
+# Example labels for bubbles
+for i in range(len(employee_performance)):
+ ax.text(employee_performance[i], happiness_scores[i], f'Emp {i+1}', fontsize=12, ha='right')
+
+# Scale sizes to percentages
+scaled_sizes = [size / max(sizes) * 100 for size in sizes]
+
+# Create legend with matching colors and percentage labels
+handles = [plt.Line2D([0], [0], marker='o', color='w', markerfacecolor=plt.cm.Greens(color / max(colors)), markersize=np.sqrt(size) / 1, label=f'{int(size)}%')
+ for color, size in zip(colors, scaled_sizes)]
+legend1 = ax.legend(handles=handles, title="Efficiency (%)", loc="center left", bbox_to_anchor=(1, 0.5), frameon=True, fontsize=10, labelspacing=2)
+ax.add_artist(legend1)
+
+# Convert the plot to an interactive HTML
+# html_str = mpld3.fig_to_html(fig)
+
+# Define Taipy page content
+page = """
+# Enhanced 2D Scatter Plot
+
+This page contains an enhanced 2D scatter plot created with Matplotlib:
+
+<|part|content={fig}|height="600px">
+"""
+
+if __name__ == "__main__":
+ Gui(page, css_file="styles.css").run(title="Chart Scatter Matplotlib")
From 8eaa8a2ca051d7dd028364c484510433496c45ae Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 18:55:45 -0400
Subject: [PATCH 11/34] Add an example on how to integrate Matplotlib
---
.../charts/matplotlib/matplotlib_scatter.py | 2 +-
doc/gui/examples/charts/matplotlib/styles.css | 13 +++++--------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py b/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py
index bfcdd78fd8..b20010b87d 100644
--- a/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py
+++ b/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py
@@ -46,7 +46,7 @@
This page contains an enhanced 2D scatter plot created with Matplotlib:
-<|part|content={fig}|height="600px">
+<|part|content={fig}|>
"""
if __name__ == "__main__":
diff --git a/doc/gui/examples/charts/matplotlib/styles.css b/doc/gui/examples/charts/matplotlib/styles.css
index d6e5161f60..65fecb5471 100644
--- a/doc/gui/examples/charts/matplotlib/styles.css
+++ b/doc/gui/examples/charts/matplotlib/styles.css
@@ -1,14 +1,11 @@
+img {
+ display: block;
+ margin: auto;
+}
+
div.taipy-part.MuiBox-root {
height: 560px;
display: flex;
align-items: center;
justify-content: center;
}
-
-img{
- display: block;
- margin-left: auto;
- margin-right: auto;
- max-height: 100%;
- max-width: 100%;
-}
From ff9c9485b801266c4112aceb63b5d2880077309e Mon Sep 17 00:00:00 2001
From: abisoyeonanuga <102636953+dottymatrix@users.noreply.github.com>
Date: Mon, 28 Oct 2024 19:02:36 -0400
Subject: [PATCH 12/34] update matplotlib scatter chart example
---
.../charts/matplotlib/matplotlib_chart.py | 47 -------------------
.../charts/matplotlib/matplotlib_scatter.py | 26 ++++++----
2 files changed, 17 insertions(+), 56 deletions(-)
delete mode 100644 doc/gui/examples/charts/matplotlib/matplotlib_chart.py
diff --git a/doc/gui/examples/charts/matplotlib/matplotlib_chart.py b/doc/gui/examples/charts/matplotlib/matplotlib_chart.py
deleted file mode 100644
index 75d5dd52d3..0000000000
--- a/doc/gui/examples/charts/matplotlib/matplotlib_chart.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import matplotlib.pyplot as plt
-import numpy as np
-import mpld3
-
-plt.style.use('_mpl-gallery')
-
-# Make the data
-np.random.seed(3)
-x = np.random.uniform(1, 6, 10) # Random x values within 1-6
-y = np.random.uniform(1, 6, 10) # Random y values within 1-6
-
-# Size and color
-sizes = np.random.uniform(300, 600, len(x)) # Adjusted sizes for better fit
-colors = np.random.uniform(50, 100, len(x)) # Greenish colors
-
-# Plot
-fig, ax = plt.subplots(figsize=(10, 6))
-scatter = ax.scatter(x, y, s=sizes, c=colors, cmap="Greens", vmin=30, vmax=80)
-ax.set(xlim=(1, 6), xticks=np.arange(1, 7), ylim=(1, 6), yticks=np.arange(1, 7))
-
-# Add axis labels
-ax.set_xlabel('Performance Score')
-ax.set_ylabel('Happiness Index')
-ax.set_title('Employee Performance vs. Happiness')
-
-# Example labels for bubbles
-for i in range(len(x)):
- ax.text(x[i], y[i], f'Employee {i+1}', fontsize=16, ha='right')
-
-# Create legend for bubble sizes
-legend_labels = np.unique(np.round(sizes, decimals=-1))
-for label in legend_labels:
- ax.scatter([], [], c='g', alpha=0.5, s=label, label=str(int(label)))
-
-legend1 = ax.legend(title="Bubble Size (Efficiency)", loc="upper right", frameon=True, fontsize=10)
-ax.legend(title="Bubble Size (Efficiency)", scatterpoints=1, labelspacing=1.5)
-ax.add_artist(legend1)
-
-# Convert the plot to an interactive HTML
-html_str = mpld3.fig_to_html(fig)
-
-# Save the HTML to a file
-with open("chart.html", "w") as f:
- f.write(html_str)
-
-# Show the plot in a browser
-mpld3.show()
diff --git a/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py b/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py
index b20010b87d..e35f1c8f3d 100644
--- a/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py
+++ b/doc/gui/examples/charts/matplotlib/matplotlib_scatter.py
@@ -1,8 +1,19 @@
-from taipy.gui import Gui
-import matplotlib.pyplot as plt
-import numpy as np
-import mpld3
-
+# Copyright 2021-2024 Avaiga Private Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations under the License.
+# -----------------------------------------------------------------------------------------
+# To execute this script, make sure that the taipy-gui package is installed in your
+# Python environment and run:
+# python