Annotations

You can annotate your renderings using Vapor’s build in annotations as well as MatPlotLib

import example_utils
from vapor import session, renderer, dataset, camera
from vapor.utils import histogram

ses = session.Session()
data = example_utils.OpenExampleDataset(ses)

ren = data.NewRenderer(renderer.TwoDDataRenderer)
ren.SetVariableName(data.GetDataVarNames(2)[1])
ses.GetCamera().ViewAll()
Vapor 3.10.0
Python 3.9.19 (/opt/anaconda3/envs/vapor)
OpenGL 4.1 Metal - 89.3

Vapor Colorbars

# Show the basic colorbar annotation for a renderer
colorbar = ren.GetColorbarAnnotation()
colorbar.SetEnabled(True)
ses.Show()
../_images/823fc8ed04fd0b6e1ee5fff69433f5579a3f727f41ab534b20ef125d2b5128a2.png
# Customized colorbar annotation
colorbar.SetSize((0.2, 0.25))
colorbar.SetTitle("Colorbar Title")
colorbar.SetCornerPosition((0.95, 0.95))
ses.Show()
UNSUPPORTED (log once): POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
../_images/ddae4454ba1d42e5cd5a1a17c3a0301459bd2fab7c5c65ad3944f18fae219fe1.png

MatPlotLib Colorbars

You can customize the histograms as you would MatPlotLib’s pylab.colorbar

tf = ren.GetPrimaryTransferFunction()
tf.ShowMatPlotLibColorbar()
../_images/629d2cd0720c260b9ca1f739dc3ca37286c2a18de02e4891f42d735e982f7172.png
tf.ShowMatPlotLibColorbar(orientation="vertical", figsize=(1.5,4))
../_images/c67d7828e774844517f5757eeb8c4f694dfaf9fc4ab1e5ba8f1328ad73894210.png
# The MatPlotLib Colorbars are automatically synced to Vapor's transfer functions
tf.LoadBuiltinColormap(tf.ListBuiltinColormaps()[7])
ses.Show()
tf.ShowMatPlotLibColorbar()
../_images/82f5c85d605fbf23042cba8703bbf8101e6203b0ac53fba2ca3770f68c35abd7.png ../_images/54ba49ca59199a8eb19c25d60cc18cbaa3da9a49936dd657158bb0f71d6eae8a.png
colorbar.SetEnabled(False)

MatPlotLib Histograms

histogram.ShowMatPlotLibHistogram(ses, ren)
../_images/a205d705df1c8cf801b777310b0185f23d7f2d357f42e3c0b8be23c2eb6d73b2.png

You can customize the histograms as you would matplotlib.pyplot.hist

plt = histogram.GetMatPlotLibHistogram(ses, ren, color ="red")
plt.xlabel("X-Axis")
plt.ylabel("Y-Axis")
plt.title("Title\n", fontweight="bold")
plt.show()
../_images/1a0c6ed998eb925c8864485dead104b662b6b6b99eee8f31aed7a48eae238ca4.png

Axis Annotations

axis = ses.GetAxisAnnotations()
axis.SetAxisAnnotationEnabled(True)
ses.Show()
../_images/1316b0010180a2692bf2512e2e6986244bf8dde06b952b4bfc9f244f7ebf8d02.png
axis.SetNumTics((5,5))
axis.SetAxisFontSize(24)
ses.Show()

# This example dataset is not geo-referenced
# axis.SetLatLonAxesEnabled(True)
../_images/bd8c18b43d671006c469f86c58f1442c27c91452307acff682afff6936a46def.png
axis.SetAxisAnnotationEnabled(False)

Scene Annotations

Scene annotations are other annotations and rendering options that apply to the entire rendering such as background color.

scene = ses.GetSceneAnnotations()
scene.SetBackgroundColor((1,1,1))
scene.SetUseDomainFrame(False)
ses.Show()
../_images/a0fa30b4cbd4662ced372595f51fa62e000639c0d5593ffa91a0d04c23ad0067.png
scene.SetAxisArrowEnabled(True)
scene.SetAxisArrowSize(0.4)

scene.SetTimeType(scene.TimeAnnotationType.Timestep)
scene.SetTimeColor((0,0,0))
scene.SetTimeLLX(0.7)

ses.Show()
../_images/56145d05d7606d3567a1b27619c8f57188551b952f238bafdae9abe8e1a49217.png