In [ ]:
import k3d
import numpy as np

points_number = 200
spread_range = 30
positions = spread_range * np.random.random_sample((points_number, 3)) - spread_range / 2
colors = np.random.randint(0, 0xFFFFFF, points_number)

plot = k3d.plot(height=240)
points = k3d.points(positions.astype(np.float32), colors.astype(np.uint32), point_size=3.0, shader='mesh')
plot += points
plot.display()
In [ ]:
plot.fetch_screenshot()

Note: this operation is asynchronous.

We need to wait for the widgets to synchronize behind the scenes...

In [ ]:
from IPython.display import Image
with open('screenshot.png', 'wb') as f:
    try:
        out = plot.screenshot.decode('base64')
    except: # Python 3
        from base64 import b64decode
        out = b64decode(plot.screenshot)    
    f.write(out)
    
Image(url='screenshot.png')

Expected result: Possible screenshot

In [ ]:
plot.screenshot_scale = 4.0
In [ ]:
plot.fetch_screenshot()

Note: this operation is asynchronous.

We need to wait for the widgets to synchronize behind the scenes...

In [ ]:
with open('screenshot_upscale.png', 'wb') as f:
    try:
        out = plot.screenshot.decode('base64')
    except: # Python 3
        from base64 import b64decode
        out = b64decode(plot.screenshot)    
    f.write(out)
In [ ]:
import imageio

print(imageio.imread('screenshot.png').shape, imageio.imread('screenshot_upscale.png').shape)
In [ ]: