import numpy as np import holoviews as hv from holoviews import opts hv.extension('matplotlib') img = hv.Image(np.random.rand(10, 10)) fig = hv.render(img) print('Figure: ', fig) print('Axes: ', fig.axes) hv.output(fig='svg') from holoviews.operation import contours x = y = np.arange(-3.0, 3.0, 0.1) X, Y = np.meshgrid(x, y) def g(x,y,c): return 2*((x-y)**2/(x**2+y**2)) + np.exp(-(np.sqrt(x**2+y**2)-c)**2) img = hv.Image(g(X,Y,2)) filled_contours = contours(img, filled=True) filled_contours hv.save(filled_contours, 'contours.png', dpi=144) from IPython.display import Image Image('contours.png', width=400) holomap = hv.HoloMap([(t, hv.Image(g(X,Y, 4 * np.sin(np.pi*t)))) for t in np.linspace(0,1,21)]).opts( cmap='fire', colorbar=True, show_title=False, xaxis='bare', yaxis='bare') contour_hmap = contours(holomap, filled=True) hv.output(contour_hmap, holomap='gif', fps=5) hv.output(contour_hmap, holomap='mp4', fps=5) hv.output(fig='png', dpi=72) filled_contours.opts(aspect=2, fig_inches=5, fig_bounds=(0, 0, 1, 1)) line_contours = contours(img).opts(aspect=3) fill_contours = filled_contours.opts(aspect=2) opts.defaults(opts.Layout(sublabel_format='', fig_size=150)) (line_contours + fill_contours).opts(tight=True) (line_contours + fill_contours).opts(aspect_weight=True, tight=True)