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

Class RibbonBox

galleries/examples/misc/demo_ribbon_box.py:19–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19class RibbonBox:
20
21 # Image.open reads this image as 8-bit; divide by 255 to convert to 0-1.
22 original_image = np.asarray(Image.open(
23 cbook.get_sample_data("Minduka_Present_Blue_Pack.png"))) / 255
24 cut_location = 70
25 b_and_h = original_image[:, :, 2:3]
26 color = original_image[:, :, 2:3] - original_image[:, :, 0:1]
27 alpha = original_image[:, :, 3:4]
28 nx = original_image.shape[1]
29
30 def __init__(self, color):
31 rgb = mcolors.to_rgb(color)
32 self.im = np.dstack(
33 [self.b_and_h - self.color * (1 - np.array(rgb)), self.alpha])
34
35 def get_stretched_image(self, stretch_factor):
36 stretch_factor = max(stretch_factor, 1)
37 ny, nx, nch = self.im.shape
38 ny2 = int(ny*stretch_factor)
39 return np.vstack(
40 [self.im[:self.cut_location],
41 np.broadcast_to(
42 self.im[self.cut_location], (ny2 - ny, nx, nch)),
43 self.im[self.cut_location:]])
44
45
46class RibbonBoxImage(AxesImage):

Callers 1

__init__Method · 0.85

Calls 1

openMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…