I am displaying some volumetric scalar data and quickly rendering the scene and saving the results to a png. This all works fine. However if I add some helpful objects such as a scalarbar or even axes to the figure it only renders the newly added scalarbar or axes.
An example,
import numpy as np
from mayavi import mlab
x, y, z = np.ogrid[-10:10:20j, -10:10:20j, -10:10:20j]
s = np.sin(x*y*z)/(x*y*z)
mlab.options.offscreen = True
fig = mlab.figure(1, bgcolor=(1., 1., 1.), size=(500, 500))
fig.scene.anti_aliasing_frames = 0
mlab.pipeline.volume(mlab.pipeline.scalar_field(s))
mlab.scalarbar() # commenting this out correctly renders, but no scalarbar
mlab.savefig('test.png')
This is actually used to create an animation, so I need to render offscreen. How can I display the volumetric data and the scalarbar?