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'
In
v0.13.3
setting axis text to element_blank results in anAttributeError
.Minimal reproduction:
Output + traceback:
pip list
withplotnine==0.13.3
:I tested with
v0.13.2
and did not get the same error.