Display DynamicMap using the full screen

Hey folks,

I’m looking at this Mandelbrot example:
https://holoviews.org/gallery/apps/bokeh/mandelbrot.html

I’ve simplified it to remove the histogram and toolbar. Now I’d like to make the dynamic map take the full screen.

Does anyone know how I could do this? I’ve been trying with panel layouts but have not been successful.

from bokeh.layouts import gridplot
import numpy as np
import holoviews as hv

from holoviews import opts
from holoviews.streams import RangeXY
from numba import jit

import panel as pn


renderer = hv.renderer('bokeh')

@jit
def mandel(real, imag, max_iters):
    """
    Given the real and imaginary parts of a complex number,
    determine if it is a candidate for membership in the Mandelbrot
    set given a fixed number of iterations.
    """
    i = 0
    c = complex(real, imag)
    z = 0.0j
    for i in range(max_iters):
        z = z*z + c
        if (z.real*z.real + z.imag*z.imag) >= 4:
            return i

    return 255

@jit
def create_fractal(min_x, max_x, min_y, max_y, image, iters):
    height = image.shape[0]
    width = image.shape[1]

    pixel_size_x = (max_x - min_x) / width
    pixel_size_y = (max_y - min_y) / height
    for x in range(width):
        real = min_x + x * pixel_size_x
        for y in range(height):
            imag = min_y + y * pixel_size_y
            color = mandel(real, imag, iters)
            image[y, x] = color

    return image

def get_fractal(x_range, y_range):
    (x0, x1), (y0, y1) = x_range, y_range
    image = np.zeros((600, 600), dtype=np.uint8)
    return hv.Image(create_fractal(x0, x1, -y1, -y0, image, 200),
                    bounds=(x0, y0, x1, y1))

range_stream = RangeXY(x_range=(-1., 1.), y_range=(-1., 1.))
dmap = hv.DynamicMap(get_fractal, label='Manderbrot Explorer', streams=[range_stream])

# The original example sets a static height and width here, but I want this to take the full screen
dmap.opts(opts.Image(cmap='fire', logz=True, xaxis=None, yaxis=None))
dmap.opts(active_tools=['wheel_zoom'], toolbar=None)

# This naive strech doesn't work either
layout = pn.Row(dmap, sizing_mode='stretch_both')

layout.servable()

Thanks for your help!

Maybe responsive = true next to the stretch both at bottom?

That doesn’t do it, no :confused:

This (almost) works for me.

def get_fractal(x_range, y_range):
    (x0, x1), (y0, y1) = x_range, y_range
    image = np.zeros((600, 600), dtype=np.uint8)
    return hv.Image(create_fractal(x0, x1, -y1, -y0, image, 200),
                    bounds=(x0, y0, x1, y1)).opts(responsive=True) 

Aah yes I think that’s good enough, thank you! I now realize I have a problem because it doesn’t keep the aspect ratio of the Mandelbrot set. But I think that’s another problem (that will probably be harder to solve).

I don’t think it is possible to do it right now because of this bug.