Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 572696690
  • Loading branch information
drewbryant authored and colaboratory-team committed Oct 11, 2023
1 parent 8f2f63c commit 320013e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion google/colab/_quickchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _ensure_dataframe_registry():

if len(numeric_cols) >= 2:
chart_sections += [
_quickchart_helpers.linked_scatter_section(
_quickchart_helpers.scatter_section(
df,
_select_first_k_pairs(numeric_cols, k=max_chart_instances),
_DATAFRAME_REGISTRY,
Expand Down
14 changes: 7 additions & 7 deletions google/colab/_quickchart_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ChartSectionType:
FACETED_DISTRIBUTION = 'faceted_distribution'
HEATMAP = 'heatmap'
HISTOGRAM = 'histogram'
LINKED_SCATTER = 'linked_scatter'
SCATTER = 'scatter'
TIME_SERIES_LINE_PLOT = 'time_series_line_plot'
VALUE_PLOT = 'value_plot'

Expand Down Expand Up @@ -330,8 +330,8 @@ def heatmaps_section(df, colname_pairs, df_registry):
)


def linked_scatter_section(df, colname_pairs, df_registry):
"""Generates a section of linked scatter plots.
def scatter_section(df, colname_pairs, df_registry):
"""Generates a section of scatter plots.
Args:
df: (pd.DataFrame) A dataframe.
Expand All @@ -340,13 +340,13 @@ def linked_scatter_section(df, colname_pairs, df_registry):
df_registry: (DataframeRegistry) Registry to use for dataframe lookups.
Returns:
(ChartSection) A chart section containing linked scatter plots.
(ChartSection) A chart section containing scatter plots.
"""
return _chart_section(
ChartSectionType.LINKED_SCATTER,
ChartSectionType.SCATTER,
df,
_quickchart_lib.scatter_plots,
[[list(colname_pairs)]],
_quickchart_lib.scatter_plot,
colname_pairs,
{},
df_registry,
'2-d distributions',
Expand Down
10 changes: 4 additions & 6 deletions google/colab/_quickchart_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,11 @@ def value_plot(df, y, figscale=1):
return autoviz.MplChart.from_current_mpl_state()


def scatter_plots(df, colname_pairs, figscale=1, alpha=.8):
def scatter_plot(df, x_colname, y_colname, figscale=1, alpha=.8):
from matplotlib import pyplot as plt
plt.figure(figsize=(len(colname_pairs) * 6 * figscale, 6 * figscale))
for plot_i, (x_colname, y_colname) in enumerate(colname_pairs, start=1):
ax = plt.subplot(1, len(colname_pairs), plot_i)
df.plot(kind='scatter', x=x_colname, y=y_colname, s=(32 * figscale), alpha=alpha, ax=ax)
ax.spines[['top', 'right',]].set_visible(False)
plt.figure(figsize=(6 * figscale, 6 * figscale))
df.plot(kind='scatter', x=x_colname, y=y_colname, s=(32 * figscale), alpha=alpha)
plt.gca().spines[['top', 'right',]].set_visible(False)
plt.tight_layout()
return autoviz.MplChart.from_current_mpl_state()

Expand Down

0 comments on commit 320013e

Please sign in to comment.