Plot options

The plot() function in k3d module creates a Plot object. There are a few options, which control the behavior and apperance of the plot:

  • height - vertical size of the plot widget
  • antialias - enables antialiasing in the WebGL renderer, its effect depends on the WebGL implementation and browser settings. On by default.
  • background_color - RGB value of the backgound color packed into a single integer.

Only the last of these options can be effectively changed once the plot is display()-ed.

In [ ]:
import k3d
plot = k3d.plot(antialias=False, height=320, camera_auto_fit=False, grid_auto_fit=False)
plot += k3d.mesh([0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 2])
plot += k3d.points([0, 0, 0])

plot.display()
plot.camera = [1.039, -0.196, -0.069,  0.25 ,  0.   ,  0.25 ,  0.426, -0.006, 0.905]
In [ ]:
plot_aa = k3d.plot(antialias=True, height=320, camera_auto_fit=False, grid_auto_fit=False)
plot_aa += k3d.mesh([0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 2])
plot_aa += k3d.points([0, 0, 0])

plot_aa.display()
plot_aa.camera = [1.039, -0.196, -0.069,  0.25 ,  0.   ,  0.25 ,  0.426, -0.006, 0.905]

Expected results:

The first plot (antialias=False) should look like this: Aliased plot

The second plot (antialias=True) should look like this: Anti-liased plot

Some objects, like the point above, are not affected by this settings.

In [ ]:
plot.background_color = 0xffff

Expected result:

Background color effect

White and black are the most popular background colors, but any RGB color can be used if so desired.

In [ ]: