Skip to content

so.Est() + tick label formatter => 'PseudoAxis' object has no attribute '_view_interval' #3585

Description

@stas-sl

Hi, thanks for cool library, I especially enjoy using objects interface.

While using it I encountered a small issue when trying to customise tick labels using matplotlib formatter in combination with so.Est(). If I replace it with so.Agg() the issue disappears. I guess this has something to do with the fact that several variables use the same scale (y/ymin/ymax) and _view_interval is not initialised properly in that case?

import seaborn as sns
import seaborn.objects as so
import matplotlib as mpl

fmri = sns.load_dataset("fmri")
(
    so.Plot(fmri, x="timepoint", y="signal", color="event")
        .add(so.Band(), so.Est())
        .scale(y=so.Continuous().label(mpl.ticker.PercentFormatter()))  
)
File ~/.pyenv/versions/miniforge3/lib/python3.9/site-packages/matplotlib/ticker.py:233, in Formatter.format_ticks(self, values)
    231 """Return the tick labels for all the ticks at once."""
    232 self.set_locs(values)
--> 233 return [self(value, i) for i, value in enumerate(values)]

File ~/.pyenv/versions/miniforge3/lib/python3.9/site-packages/matplotlib/ticker.py:233, in <listcomp>(.0)
    231 """Return the tick labels for all the ticks at once."""
    232 self.set_locs(values)
--> 233 return [self(value, i) for i, value in enumerate(values)]

File ~/.pyenv/versions/miniforge3/lib/python3.9/site-packages/matplotlib/ticker.py:1525, in PercentFormatter.__call__(self, x, pos)
   1523 def __call__(self, x, pos=None):
   1524     """Format the tick as a percentage with the appropriate scaling."""
-> 1525     ax_min, ax_max = self.axis.get_view_interval()
   1526     display_range = abs(ax_max - ax_min)
   1527     return self.fix_minus(self.format_pct(x, display_range))

File ~/.pyenv/versions/miniforge3/lib/python3.9/site-packages/seaborn/_core/scales.py:921, in PseudoAxis.get_view_interval(self)
    920 def get_view_interval(self):
--> 921     return self._view_interval

AttributeError: 'PseudoAxis' object has no attribute '_view_interval'

Versions:
seaborn: 0.13.0
matplotlib: 3.6.2

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions