MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / bar

Method bar

lib/mpl_toolkits/mplot3d/axes3d.py:3248–3305  ·  view source on GitHub ↗

Add 2D bar(s). Parameters ---------- left : 1D array-like The x coordinates of the left sides of the bars. height : 1D array-like The height of the bars. zs : float or 1D array-like, default: 0 Z coordinate of bars

(self, left, height, zs=0, zdir='z', *args,
            axlim_clip=False, **kwargs)

Source from the content-addressed store, hash-verified

3246
3247 @_preprocess_data()
3248 def bar(self, left, height, zs=0, zdir='z', *args,
3249 axlim_clip=False, **kwargs):
3250 """
3251 Add 2D bar(s).
3252
3253 Parameters
3254 ----------
3255 left : 1D array-like
3256 The x coordinates of the left sides of the bars.
3257 height : 1D array-like
3258 The height of the bars.
3259 zs : float or 1D array-like, default: 0
3260 Z coordinate of bars; if a single value is specified, it will be
3261 used for all bars.
3262 zdir : {'x', 'y', 'z'}, default: 'z'
3263 When plotting 2D data, the direction to use as z ('x', 'y' or 'z').
3264 axlim_clip : bool, default: False
3265 Whether to hide bars with points outside the axes view limits.
3266
3267 .. versionadded:: 3.10
3268 data : indexable object, optional
3269 DATA_PARAMETER_PLACEHOLDER
3270 **kwargs
3271 Other keyword arguments are forwarded to
3272 `matplotlib.axes.Axes.bar`.
3273
3274 Returns
3275 -------
3276 mpl_toolkits.mplot3d.art3d.Patch3DCollection
3277 """
3278 had_data = self.has_data()
3279
3280 patches = super().bar(left, height, *args, **kwargs)
3281
3282 zs = np.broadcast_to(zs, len(left), subok=True)
3283
3284 verts = []
3285 verts_zs = []
3286 for p, z in zip(patches, zs):
3287 vs = art3d._get_patch_verts(p)
3288 verts += vs.tolist()
3289 verts_zs += [z] * len(vs)
3290 art3d.patch_2d_to_3d(p, z, zdir, axlim_clip)
3291 if 'alpha' in kwargs:
3292 p.set_alpha(kwargs['alpha'])
3293
3294 if len(verts) > 0:
3295 # the following has to be skipped if verts is empty
3296 # NOTE: Bugs could still occur if len(verts) > 0,
3297 # but the "2nd dimension" is empty.
3298 xs, ys = zip(*verts)
3299 else:
3300 xs, ys = [], []
3301
3302 xs, ys, verts_zs = art3d.juggle_axes(xs, ys, verts_zs, zdir)
3303 self.auto_scale_xyz(xs, ys, verts_zs, had_data)
3304
3305 return patches

Callers 2

test_bar3dFunction · 0.45
test_legend_barFunction · 0.45

Calls 3

auto_scale_xyzMethod · 0.95
has_dataMethod · 0.80
set_alphaMethod · 0.45

Tested by 2

test_bar3dFunction · 0.36
test_legend_barFunction · 0.36