Skip to content

Commit b79b9c6

Browse files
committed
Try to disable relative bar widths for external packages
1 parent 5003f9a commit b79b9c6

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

docs/stats.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
# section should be read before this section. Some of these tools will be
3030
# expanded in the future, but for a more comprehensive suite of statistical
3131
# plotting utilities, you may be interested in `seaborn`_ (we try to ensure
32-
# that seaborn plotting commands are compatible with ProPlot axes
33-
# and figures but this is a work in progress).
32+
# that seaborn plotting commands are compatible with ProPlot figures and axes).
3433

3534
# %% [raw] raw_mimetype="text/restructuredtext"
3635
# .. _ug_errorbars:

proplot/axes/plot.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import inspect
77
import itertools
88
import re
9+
import sys
910
from numbers import Integral
1011

1112
import matplotlib.axes as maxes
@@ -3252,7 +3253,7 @@ def _convert_bar_width(x, width=1):
32523253
return width * x_step
32533254

32543255
def _apply_bar(
3255-
self, xs, hs, ws, bs, *, absolute_width=False,
3256+
self, xs, hs, ws, bs, *, absolute_width=None,
32563257
stack=None, stacked=None, negpos=False, orientation='vertical', **kwargs
32573258
):
32583259
"""
@@ -3266,6 +3267,18 @@ def _apply_bar(
32663267
xs, hs, kw = self._parse_plot1d(xs, hs, orientation=orientation, **kw)
32673268
edgefix_kw = _pop_params(kw, self._apply_edgefix)
32683269

3270+
# Default absolute width with horrible kludge
3271+
# (the faint of heart should look away now).
3272+
if absolute_width is None:
3273+
frame = sys._getframe()
3274+
absolute_width = False
3275+
absolute_names = ('seaborn.distributions', 'seaborn.categorical')
3276+
while frame is not None:
3277+
if frame.f_globals.get('__name__', '') in absolute_names:
3278+
absolute_width = True
3279+
break
3280+
frame = frame.f_back
3281+
32693282
# Call func after converting bar width
32703283
b0 = 0
32713284
objs = []

proplot/internals/warnings.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def _warn_proplot(message, action=None):
2525
"""
2626
frame = sys._getframe()
2727
stacklevel = 1
28-
while True:
29-
if frame is None:
30-
break # when called in embedded context this may happen
28+
while frame is not None:
3129
if not REGEX_INTERNAL.match(frame.f_globals.get('__name__', '')):
3230
break # this is the first external frame
3331
frame = frame.f_back

0 commit comments

Comments
 (0)