7 examples of 'matplotlib multiple plots same figure' in Python

Every line of 'matplotlib multiple plots same figure' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
345def __prepare_plot_with_matplotlib(
346 wrange, figsize, grid, wireframe, noaxis):
347 import matplotlib.pyplot as plt
348
349 fig = plt.figure(figsize=(figsize, figsize))
350 ax = fig.gca()
351 ax.set_aspect('equal')
352
353 # if wireframe:
354 # ax.w_xaxis.set_pane_color((0, 0, 0, 0))
355 # ax.w_yaxis.set_pane_color((0, 0, 0, 0))
356 # ax.w_zaxis.set_pane_color((0, 0, 0, 0))
357
358 ax.grid(grid)
359 ax.set_xlim(*wrange['x'])
360 ax.set_ylim(*wrange['y'])
361 ax.set_xlabel('X')
362 ax.set_ylabel('Y')
363
364 if noaxis:
365 ax.set_axis_off()
366
367 return (fig, ax)
57def plot(X, y, title, min_label, maj_label, filename):
58 plt.figure(figsize= (4, 3))
59 plt.scatter(X[:,0][y == min_label], X[:,1][y == min_label], label='minority class', color='red', s=25)
60 plt.scatter(X[:,0][y == maj_label], X[:,1][y == maj_label], label='majority class', color='black', marker='*', s=25)
61 plt.xlabel('feature 0')
62 plt.ylabel('feature 1')
63 plt.title(title)
64 plt.legend()
65 plt.tight_layout()
66 plt.savefig(filename)
67 plt.show()
51def decorate_singleplot(ax, **kwarg):
52 ax.axis('tight')
53 ax.set_yscale('log')
54 ax.set(**kwarg)
261def subplot(self, axes, subfigure):
262 """
263 Draw a line plot on an :class:`matplotlib.axes` instance. The
264 data and labels are contained in a tuple. This will plot two
265 lines and a grey range (for displaying uncertainty). A grid is
266 added with a call to :meth:`RangeFigure.addGrid`.
267
268 :param axes: :class:`matplotlib.axes` instance.
269 :param tuple subfigure: Holds the data and labels to be added
270 to the subplot.
271 """
272 xdata, y1, y2, y2max, y2min, xlabel, ylabel, title = subfigure
273
274 axes.plot(xdata, y1, color='r', lw=2, label="")
275 axes.plot(xdata, y2, color='k', lw=2, label="")
276 self.addRange(axes, xdata, y2min, y2max)
277
278 axes.set_xlabel(xlabel)
279 axes.set_ylabel(ylabel)
280 axes.set_title(title)
281 axes.autoscale(True, axis='x', tight=True)
282 self.addGrid(axes)
15def plots(ims, figsize=(16, 8), rows=None, cols=None, interp=False, titles=None):
16 plt.figure(figsize=figsize)
17 cols, num_splits, rows = _set_params(cols, rows)
18
19 tmp_num_splits = len(ims) // num_splits
20 if tmp_num_splits * num_splits < len(ims):
21 tmp_num_splits += 1
22
23 for i in range(len(ims)):
24
25 if rows is not None:
26 sp = plt.subplot(num_splits, tmp_num_splits, i + 1)
27 if cols is not None:
28 sp = plt.subplot(tmp_num_splits, num_splits, i + 1)
29 sp.axis('Off')
30
31 if titles is not None:
32 sp.set_title(titles[i], fontsize=16)
33
34 plt.imshow(ims[i], interpolation=None if interp else 'none')
35 plt.show()
466def subplot(self, axes, subfigure):
467 """
468 Draw a range-compare plot on an :class:`matplotlib.axes`
469 instance, with a logarithmic scale on the x-axis. Data and
470 labels are contained in a tuple. x-ticks presented as integer
471 values. A grid is added with a call to
472 :meth:`RangeFigure.addGrid`.
473
474 :param axes: :class:`matplotlib.axes` instance.
475 :param tuple subfigure: Holds the data and labels to be added
476 to the subplot.
477
478 """
479 xdata, y1, y2, y2max, y2min, xlabel, ylabel, title = subfigure
480
481 axes.semilogx(xdata, y1, color='r', lw=2, label="", subsx=xdata)
482 axes.semilogx(xdata, y2, color='k', lw=2, label="", subsx=xdata)
483 self.addRange(axes, xdata, y2min, y2max)
484 ylim = (0., np.max([100, np.ceil(y2.max()/10.)*10.]))
485 axes.set_ylim(ylim)
486
487 axes.set_xlabel(xlabel)
488 axes.set_ylabel(ylabel)
489 axes.set_title(title)
490 self.addGrid(axes)
225def draw_plot(figure_label, x, y, i_labels, fnme, name, left_legend=False):
226 """
227 "blues": 0,
228 "country": 1,
229 "jazz": 2,
230 "pop": 3,
231 "rock": 4,
232 "classical": 5,
233 "disco": 6,
234 "hiphop": 7,
235 "metal": 8,
236 "reggae": 9
237 """
238 colors = root.colors
239
240 fig = pp.figure(figure_label)
241 ax = fig.add_subplot(111)
242 # ax.set_ylim(0, 1)
243 ax.set_title(name if len(name) else fnme, fontsize=root.title_fontsize)
244 for i in range(len(y)):
245 ax.plot(x, y[i], color=colors[i], label=i_labels[i], linewidth=4)
246 ax.fill_between(x, y[0], 0, color=colors[0])
247 for i in range(1, len(y)):
248 ax.fill_between(x, y[i], y[i - 1], color=colors[i])
249
250 if left_legend:
251 ax.legend(ncol=3, loc=2)
252 else:
253 ax.legend(ncol=3)

Related snippets