Skip to content

Commit

Permalink
limiting labels to 23 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
brifordwylie committed Dec 11, 2024
1 parent 63e788f commit cc908ff
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion applications/aws_dashboard/pages/models/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def models_layout(
plugin_rows = [
dbc.Row(
plugin,
style={"padding": "0px 0px 0px 0px"},
style={"padding": "0px 0px 20px 0px"}
)
for component_id, plugin in kwargs.items()
]
Expand Down
8 changes: 5 additions & 3 deletions src/sageworks/web_interface/components/correlation_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ def update_properties(self, data_source_details: dict) -> go.Figure:
)
fig.update_layout(margin={"t": 10, "b": 10, "r": 10, "l": 10, "pad": 0}, height=height)

# Now remap the x and y axis labels (so they don't show the index)
fig.update_xaxes(tickvals=x_labels, ticktext=df.columns, tickangle=30, showgrid=False)
fig.update_yaxes(tickvals=y_labels, ticktext=df.index, showgrid=False)
# Truncate labels to a maximum of 23 characters
x_axes_labels = [f"{c[:20]}..." if len(c) > 23 else c for c in df.columns]
y_axes_labels = [f"{c[:20]}..." if len(c) > 23 else c for c in df.index]
fig.update_xaxes(tickvals=x_labels, ticktext=x_axes_labels, tickangle=30, showgrid=False)
fig.update_yaxes(tickvals=y_labels, ticktext=y_axes_labels, showgrid=False)

# Now we're going to customize the annotations and filter out low values
for i, row in enumerate(df.index):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def update_properties(self, model: CachedModel, **kwargs) -> list:
# Apply theme-based layout updates
fig.update_layout(
template=pio.templates.default, # Use the current theme
margin=dict(l=90, r=10, t=15, b=70), # Custom margins
margin=dict(l=100, r=10, t=15, b=80), # Custom margins
height=360, # Fixed height for consistent layout
xaxis_title="Predicted", # Add meaningful axis labels
yaxis_title="Actual",
Expand Down
2 changes: 1 addition & 1 deletion src/sageworks/web_interface/components/regression_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def update_properties(self, model: Model, inference_run: str) -> go.Figure:
)

# Just some fine-tuning of the plot
fig.update_layout(margin=dict(l=70, r=10, t=15, b=50), height=360) # Custom margins
fig.update_layout(margin=dict(l=80, r=10, t=15, b=60), height=360) # Custom margins

return fig

Expand Down
4 changes: 3 additions & 1 deletion src/sageworks/web_interface/components/violin_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def update_properties(self, df: pd.DataFrame, figure_args: dict, max_plots: int
num_rows, num_columns = self._compute_subplot_layout(num_plots)
fig = make_subplots(rows=num_rows, cols=num_columns, vertical_spacing=0.07)
for i, col in enumerate(numeric_columns):
# Truncate labels to a maximum of 23 characters
label = f"{col[:20]}..." if len(col) > 23 else col
fig.add_trace(
go.Violin(y=df[col], name=col, **figure_args),
go.Violin(y=df[col], name=label, **figure_args),
row=i // num_columns + 1,
col=i % num_columns + 1,
)
Expand Down

0 comments on commit cc908ff

Please sign in to comment.