In v0.13.3 setting axis text to element_blank results in an AttributeError.
Minimal reproduction:
from plotnine import (
ggplot,
geom_point,
aes,
theme,
element_blank,
)
from plotnine.data import mpg
p = ggplot(mpg, aes("displ", "hwy")) + geom_point()
p.save("plot.svg")
(p + theme(axis_text_x=element_blank())).save("plot-no-x-label.svg")
Output + traceback:
/home/daylin/tmp/repro-plotnine-error/.venv/lib/python3.11/site-packages/plotnine/ggplot.py:604: PlotnineWarning: Saving 6.4 x 4.8 in image.
/home/daylin/tmp/repro-plotnine-error/.venv/lib/python3.11/site-packages/plotnine/ggplot.py:605: PlotnineWarning: Filename: plot.svg
/home/daylin/tmp/repro-plotnine-error/.venv/lib/python3.11/site-packages/plotnine/ggplot.py:604: PlotnineWarning: Saving 6.4 x 4.8 in image.
/home/daylin/tmp/repro-plotnine-error/.venv/lib/python3.11/site-packages/plotnine/ggplot.py:605: PlotnineWarning: Filename: plot-no-x-label.svg
Traceback (most recent call last):
File "/home/daylin/tmp/repro-plotnine-error/plot.py", line 16, in <module>
(p + theme(axis_text_x=element_blank())).save("plot-no-x-label.svg")
File "/home/daylin/tmp/repro-plotnine-error/.venv/lib/python3.11/site-packages/plotnine/ggplot.py", line 661, in save
sv = self.save_helper(
^^^^^^^^^^^^^^^^^
File "/home/daylin/tmp/repro-plotnine-error/.venv/lib/python3.11/site-packages/plotnine/ggplot.py", line 610, in save_helper
figure = self.draw(show=False)
^^^^^^^^^^^^^^^^^^^^^
File "/home/daylin/tmp/repro-plotnine-error/.venv/lib/python3.11/site-packages/plotnine/ggplot.py", line 281, in draw
self._draw_breaks_and_labels()
File "/home/daylin/tmp/repro-plotnine-error/.venv/lib/python3.11/site-packages/plotnine/ggplot.py", line 458, in _draw_breaks_and_labels
self.facet.set_limits_breaks_and_labels(panel_params, ax)
File "/home/daylin/tmp/repro-plotnine-error/.venv/lib/python3.11/site-packages/plotnine/facets/facet.py", line 350, in set_limits_breaks_and_labels
pad_x = margin.get_as("t", "pt")
^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get_as'
pip list with plotnine==0.13.3:
Package Version
--------------- -----------
contourpy 1.2.0
cycler 0.12.1
fonttools 4.50.0
kiwisolver 1.4.5
matplotlib 3.8.3
mizani 0.11.1
numpy 1.26.4
packaging 24.0
pandas 2.2.1
patsy 0.5.6
pillow 10.2.0
pip 24.0
plotnine 0.13.3
pyparsing 3.1.2
python-dateutil 2.9.0.post0
pytz 2024.1
scipy 1.12.0
setuptools 65.5.0
six 1.16.0
statsmodels 0.14.1
tzdata 2024.1
I tested with v0.13.2 and did not get the same error.
In
v0.13.3setting axis text to element_blank results in anAttributeError.Minimal reproduction:
Output + traceback:
pip listwithplotnine==0.13.3:I tested with
v0.13.2and did not get the same error.