exPlotFigure.cpp
Render a retained line plot. Record one training-loss series, render the retained figure through OA's GPU compositor, save it, and optionally inspect it in Viewer.
ExSDK source-ownedC++Ui
Source
Ui · Vulkan graphics
Example
1#include <oa/oa.h>23OA_MAIN_MODE("ExamplePlotLine", argc > 1 and oa::StringView(argv[1]) == "--preview" ? oa::PresentationMode::Swapchain : oa::PresentationMode::Headless) {4 oa::plot::Figure figure({5 .title = "Training loss",6 .width = 960U,7 .height = 540U,8 .theme = oa::plot::Theme::Dark,9 });10 constexpr oa::Array<oa::F32, 6> figureValues{11 1.0F, 0.72F, 0.51F, 0.38F, 0.29F, 0.23F12 };13 figure.ax(0, 0).xLabel("step");14 figure.ax(0, 0).yLabel("loss");15 figure.ax(0, 0).plot(figureValues);1617 auto renderedResult = figure.render(engine);18 if (not renderedResult.isOk()) return 1;19 auto rendered = oa::move(renderedResult).getValue();2021 const oa::Path output = oa::Paths::var("example/ui/trainingLoss.jpg");22 if (not oa::Filesystem::createDirectories(output.parentPath()).isOk()) return 1;23 if (not oa::FnImage::saveFile(output, rendered, 92U).isOk()) return 1;2425 if (not rendered.validate()) return 1;26 if (rendered.width() != 960 or rendered.height() != 540) return 1;27 if (rendered.format() != oa::ImageFormat::Rgba) return 1;28 if (not oa::Filesystem::isFile(output)) return 1;2930 oa::print("Saved training-loss plot: {}", output.cStr());3132 if (argc > 1 and oa::StringView(argv[1]) == "--preview") {33 oa::ViewerConfig previewConfig;34 previewConfig.mode = oa::ViewerMode::Image;35 previewConfig.title = "OA plot · training loss";36 previewConfig.width = 1280U;37 previewConfig.height = 646U;38 if (not oa::Viewer::preview(engine, oa::Paths::var("example/ui/trainingLoss.jpg").string(),39 previewConfig).isOk()) {40 return 1;41 }42 }43 return 0;44}45
Output
Rendered plot. This is the exact 960×540 JPEG produced by the retained figure in the source-owned example.

output
Training loss
A dark retained line plot rendered by OA's GPU compositor and saved through oa::FnImage.
960×540 · image/jpegSHA-256 7c60f7dea23a4180641016ef05eae0c3672bb784570d52f1aa44fcaada2ba762sdk/py/examples/ui/plotFigure.py
Present
The Output section above remains the exact artifact evidence. These captures document the current interactive Viewer surface used by the presentation path.

OA Viewer · Presented state
oa::Viewer
The saved plot opened by this example's optional --preview path in OA's native GPU image viewer.
1280×720 · JPEGSHA-256 26f7e9b1a9fd5adf…bin/release/sdk/examples/ui/examplePlotLine --preview