Skip to content

bug in sqlplot #1058

@DaiZack

Description

@DaiZack

What happens?

%sqlplot boxplot --table penguins.csv --column body_mass_g

I got


AttributeError Traceback (most recent call last)
Cell In[27], line 1
----> 1 get_ipython().run_line_magic('sqlplot', 'boxplot --table penguins.csv --column body_mass_g')

File ~/playground/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py:2486, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
2484 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2485 with self.builtin_trap:
-> 2486 result = fn(*args, **kwargs)
2488 # The code below prevents the output from being displayed
2489 # when using magics with decorator @output_can_be_silenced
2490 # when the last Python token in the expression is a ';'.
2491 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File ~/playground/.venv/lib/python3.12/site-packages/sql/magic_plot.py:105, in SqlPlotMagic.execute(self, line, cell, local_ns)
102 with_ = self.check_table_exists(table, schema)
104 if cmd.args.plot_name in {"box", "boxplot"}:
--> 105 return plot.boxplot(
106 table=table,
107 column=column,
108 with
=with_,
109 orient=cmd.args.orient,
110 conn=None,
111 schema=schema,
112 )
113 elif cmd.args.plot_name in {"hist", "histogram"}:
114 # to avoid passing bins default value when breaks or binwidth is specified
115 bin_specified = " --bins " in line or " -b " in line

File ~/playground/.venv/lib/python3.12/site-packages/ploomber_core/dependencies.py:40, in requires..decorator..wrapper(*args, **kwargs)
32 @wraps(f)
33 def wrapper(*args, **kwargs):
34 check_installed(
35 pkgs=pkgs,
36 name=name or f.name,
37 extra_msg=extra_msg,
38 pip_names=pip_names,
39 )
---> 40 return f(*args, **kwargs)

File ~/playground/.venv/lib/python3.12/site-packages/sql/plot.py:232, in boxplot(table, column, orient, with_, conn, ax, schema)
229 if schema:
230 _table = f'"{schema}"."{_table}"'
--> 232 ax = ax or plt.gca()
233 vert = orient == "v"
235 set_ticklabels = ax.set_xticklabels if vert else ax.set_yticklabels

AttributeError: 'NoneType' object has no attribute 'gca'

Environment
requires-python = ">=3.12"
dependencies = [
"duckdb>=1.3.0",
"duckdb-engine>=0.17.0",
"ipykernel>=6.29.5",
"jupysql>=0.11.1",
"matplotlib>=3.10.3",
"pandas>=2.2.3",
]

To Reproduce

%sqlplot boxplot --table penguins.csv --column body_mass_g

OS:

linux

JupySQL Version:

0.11.1

Full Name:

Zack

Affiliation:

Brock University

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions