- 
                Notifications
    You must be signed in to change notification settings 
- Fork 749
improvement: print matplotlib Figures/Axes in rich table output #6904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
98b7d3f
              c66c76f
              be6d0f4
              915b330
              2f1e2b6
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # /// script | ||
| # requires-python = ">=3.11" | ||
| # dependencies = [ | ||
| # "pandas", | ||
| # "matplotlib", | ||
| # ] | ||
| # /// | ||
|  | ||
| import marimo | ||
|  | ||
| __generated_with = "0.17.0" | ||
| app = marimo.App(width="medium") | ||
|  | ||
|  | ||
| @app.cell | ||
| def _(): | ||
| import marimo as mo | ||
| return (mo,) | ||
|  | ||
|  | ||
| @app.cell(hide_code=True) | ||
| def _(mo): | ||
| mo.md( | ||
| """ | ||
| # Issue #6893: Pandas Subplots Not Displaying | ||
|  | ||
| This smoke test reproduces the issue where pandas DataFrame box plots | ||
| with `subplots=True` don't render properly in marimo. | ||
|  | ||
| **Expected behavior**: Box plots should display as images | ||
|  | ||
| **Actual behavior**: Only textual representation appears | ||
|  | ||
| The issue occurs because `df.plot.box(subplots=True)` returns a numpy | ||
| ndarray of matplotlib Axes objects, which marimo doesn't currently format. | ||
| """ | ||
| ) | ||
| return | ||
|  | ||
|  | ||
| @app.cell | ||
| def _(): | ||
| import pandas as pd | ||
| import matplotlib | ||
|  | ||
| # Load NYC taxi data from stable GitHub URL | ||
| taxi_url = ( | ||
| "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/taxis.csv" | ||
| ) | ||
| df = pd.read_csv(taxi_url) | ||
| df | ||
| return (df,) | ||
|  | ||
|  | ||
| @app.cell(hide_code=True) | ||
| def _(mo): | ||
| mo.md("""## Test Case 1: Box plot WITHOUT subplots (works correctly)""") | ||
| return | ||
|  | ||
|  | ||
| @app.cell | ||
| def _(df): | ||
| # This should work - returns a single Axes object | ||
| df[["distance", "total"]].plot.box() | ||
| return | ||
|  | ||
|  | ||
| @app.cell(hide_code=True) | ||
| def _(mo): | ||
| mo.md( | ||
| """ | ||
| ## Test Case 2: Box plot WITH subplots (reproduces issue #6893) | ||
|  | ||
| This is the exact scenario from the bug report. | ||
| """ | ||
| ) | ||
| return | ||
|  | ||
|  | ||
| @app.cell | ||
| def _(df): | ||
| # This reproduces the issue - returns ndarray of Axes | ||
| df[["distance", "total"]].plot.box(subplots=True) | ||
| return | ||
|  | ||
|  | ||
| @app.cell(hide_code=True) | ||
| def _(mo): | ||
| mo.md("""## Test Case 3: Multiple subplots with custom layout""") | ||
| return | ||
|  | ||
|  | ||
| @app.cell | ||
| def _(df): | ||
| # Test with 2x2 layout - also returns ndarray of Axes | ||
| df[["distance", "total", "fare", "tip"]].plot.box( | ||
| subplots=True, layout=(2, 2), figsize=(10, 8) | ||
| ) | ||
| return | ||
|  | ||
|  | ||
| @app.cell(hide_code=True) | ||
| def _(mo): | ||
| mo.md( | ||
| """ | ||
| ## Test Case 4: 1D array of subplots | ||
|  | ||
| Test with a single row of subplots. | ||
| """ | ||
| ) | ||
| return | ||
|  | ||
|  | ||
| @app.cell | ||
| def _(df): | ||
| # Returns 1D ndarray of Axes | ||
| df[["fare", "tip", "tolls"]].plot.box(subplots=True, layout=(1, 3)) | ||
| return | ||
|  | ||
|  | ||
| if __name__ == "__main__": | ||
| app.run() | 
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't think this file is needed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its just a smoke test, i don't see any harm in having a repro commited to the codebase There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, it just seemed irrelevant to this issue & a normal duckdb error. but okay to include | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import marimo | ||
|  | ||
| __generated_with = "0.17.0" | ||
| app = marimo.App(width="medium", sql_output="native") | ||
|  | ||
|  | ||
| @app.cell | ||
| def _(): | ||
| import marimo as mo | ||
| import pandas as pd | ||
| import numpy as np | ||
| import sqlglot | ||
| import pyarrow | ||
| return np, pd | ||
|  | ||
|  | ||
| @app.cell | ||
| def _(np, pd): | ||
| example_df = pd.DataFrame( | ||
| [ | ||
| [np.random.random(size=[2, 2]) for _col in range(2)] | ||
| for _row in range(3) | ||
| ], | ||
| columns=["A", "B"], | ||
| ) | ||
| return (example_df,) | ||
|  | ||
|  | ||
| @app.cell | ||
| def _(example_df): | ||
| import duckdb | ||
|  | ||
| res = duckdb.sql( | ||
| f""" | ||
| SELECT COUNT(*) FROM example_df | ||
| """, | ||
| ) | ||
| print(res) | ||
| return | ||
|  | ||
|  | ||
| if __name__ == "__main__": | ||
| app.run() | 
Uh oh!
There was an error while loading. Please reload this page.