(objects='mhip', fmt="pdf", usetex=False)
| 23 | |
| 24 | |
| 25 | def _save_figure(objects='mhip', fmt="pdf", usetex=False): |
| 26 | mpl.use(fmt) |
| 27 | mpl.rcParams.update({'svg.hashsalt': 'asdf', 'text.usetex': usetex}) |
| 28 | |
| 29 | def plot_markers(fig): |
| 30 | # use different markers... |
| 31 | ax = fig.add_subplot() |
| 32 | x = range(10) |
| 33 | ax.plot(x, [1] * 10, marker='D') |
| 34 | ax.plot(x, [2] * 10, marker='x') |
| 35 | ax.plot(x, [3] * 10, marker='^') |
| 36 | ax.plot(x, [4] * 10, marker='H') |
| 37 | ax.plot(x, [5] * 10, marker='v') |
| 38 | |
| 39 | def plot_hatch(fig): |
| 40 | # also use different hatch patterns |
| 41 | ax2 = fig.add_subplot() |
| 42 | bars = (ax2.bar(range(1, 5), range(1, 5)) + |
| 43 | ax2.bar(range(1, 5), [6] * 4, bottom=range(1, 5))) |
| 44 | ax2.set_xticks([1.5, 2.5, 3.5, 4.5]) |
| 45 | |
| 46 | patterns = ('-', '+', 'x', '\\', '*', 'o', 'O', '.') |
| 47 | for bar, pattern in zip(bars, patterns): |
| 48 | bar.set_hatch(pattern) |
| 49 | |
| 50 | def plot_image(fig): |
| 51 | axs = fig.subplots(1, 3, sharex=True, sharey=True) |
| 52 | # also use different images |
| 53 | A = [[1, 2, 3], [2, 3, 1], [3, 1, 2]] |
| 54 | axs[0].imshow(A, interpolation='nearest') |
| 55 | A = [[1, 3, 2], [1, 2, 3], [3, 1, 2]] |
| 56 | axs[1].imshow(A, interpolation='bilinear') |
| 57 | A = [[2, 3, 1], [1, 2, 3], [2, 1, 3]] |
| 58 | axs[2].imshow(A, interpolation='bicubic') |
| 59 | |
| 60 | def plot_paths(fig): |
| 61 | # clipping support class, copied from demo_text_path.py gallery example |
| 62 | class PathClippedImagePatch(PathPatch): |
| 63 | """ |
| 64 | The given image is used to draw the face of the patch. Internally, |
| 65 | it uses BboxImage whose clippath set to the path of the patch. |
| 66 | |
| 67 | FIXME : The result is currently dpi dependent. |
| 68 | """ |
| 69 | |
| 70 | def __init__(self, path, bbox_image, **kwargs): |
| 71 | super().__init__(path, **kwargs) |
| 72 | self.bbox_image = BboxImage( |
| 73 | self.get_window_extent, norm=None, origin=None) |
| 74 | self.bbox_image.set_data(bbox_image) |
| 75 | |
| 76 | def set_facecolor(self, color): |
| 77 | """Simply ignore facecolor.""" |
| 78 | super().set_facecolor("none") |
| 79 | |
| 80 | def draw(self, renderer=None): |
| 81 | # the clip path must be updated every draw. any solution? -JJ |
| 82 | self.bbox_image.set_clip_path(self._path, self.get_transform()) |
nothing calls this directly
no test coverage detected
searching dependent graphs…