Spaces:
Runtime error
Runtime error
Commit
·
d808656
1
Parent(s):
48664e3
adjust plot size
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import seaborn as sns
|
|
5 |
from matplotlib import pyplot as plt
|
6 |
|
7 |
sns.set_style(style="darkgrid")
|
8 |
-
sns.set_context(context="notebook", font_scale=0.
|
9 |
|
10 |
MAX_NOISE = 20
|
11 |
DEFAULT_NOISE = 6
|
@@ -108,14 +108,26 @@ def make_plot(
|
|
108 |
)
|
109 |
|
110 |
plt.xlabel("\nx")
|
111 |
-
plt.ylabel("
|
112 |
plt.legend(fontsize=7.5)
|
113 |
plt.tight_layout()
|
114 |
plt.show()
|
115 |
return fig
|
116 |
|
117 |
-
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
with gr.Row():
|
120 |
with gr.Column():
|
121 |
with gr.Row():
|
@@ -156,7 +168,7 @@ with gr.Blocks() as demo:
|
|
156 |
show_params.append(gr.Checkbox(label="Show Added Noise", value=True))
|
157 |
show_params.append(gr.Checkbox(label="Show Noisy Points", value=True))
|
158 |
|
159 |
-
scatter_plot = gr.Plot()
|
160 |
|
161 |
num_points.change(fn=make_plot, inputs=[num_points, noise_level, process_params, *show_params], outputs=scatter_plot)
|
162 |
noise_level.change(fn=make_plot, inputs=[num_points, noise_level, process_params, *show_params], outputs=scatter_plot)
|
|
|
5 |
from matplotlib import pyplot as plt
|
6 |
|
7 |
sns.set_style(style="darkgrid")
|
8 |
+
sns.set_context(context="notebook", font_scale=0.7)
|
9 |
|
10 |
MAX_NOISE = 20
|
11 |
DEFAULT_NOISE = 6
|
|
|
108 |
)
|
109 |
|
110 |
plt.xlabel("\nx")
|
111 |
+
plt.ylabel("y")
|
112 |
plt.legend(fontsize=7.5)
|
113 |
plt.tight_layout()
|
114 |
plt.show()
|
115 |
return fig
|
116 |
|
117 |
+
# Force main column to be 100 pixels wide, knowing that the parent is a flex container with column direction
|
118 |
+
css = """
|
119 |
+
.gradio-container {
|
120 |
+
width: min(1000px, 50%)!important;
|
121 |
+
min-width: 800px;
|
122 |
+
}
|
123 |
+
.main-plot {
|
124 |
+
background-color: blue;
|
125 |
+
padding: auto;
|
126 |
+
margin: auto;
|
127 |
+
width: 85%!important;
|
128 |
+
}
|
129 |
+
"""
|
130 |
+
with gr.Blocks(css=css) as demo:
|
131 |
with gr.Row():
|
132 |
with gr.Column():
|
133 |
with gr.Row():
|
|
|
168 |
show_params.append(gr.Checkbox(label="Show Added Noise", value=True))
|
169 |
show_params.append(gr.Checkbox(label="Show Noisy Points", value=True))
|
170 |
|
171 |
+
scatter_plot = gr.Plot(elem_classes=["main-plot"])
|
172 |
|
173 |
num_points.change(fn=make_plot, inputs=[num_points, noise_level, process_params, *show_params], outputs=scatter_plot)
|
174 |
noise_level.change(fn=make_plot, inputs=[num_points, noise_level, process_params, *show_params], outputs=scatter_plot)
|