Hello World Example
This example demonstrates the most basic usage of the plotly.cpp library by creating a simple scatter plot with both line and marker visualization.
What You'll Learn
- Basic plot creation with scatter traces
- Layout configuration with titles
- Interactive browser display vs headless image export
- Command line argument parsing for different execution modes
Sample Output
The example creates a scatter plot with the following data points:
- X coordinates: [1, 2, 3, 4, 5]
- Y coordinates: [1, 4, 2, 8, 5]
The resulting plot shows both line connections and individual markers, with the title "Hello World!" displayed at the top.
Hello World Example Output
- See also
- plotly::Figure For the main plotting interface
-
parseGalleryArgs() For command line argument handling
#include <vector>
auto main(
int argc,
char *argv[]) ->
int {
std::vector<double> x = {1, 2, 3, 4, 5};
std::vector<double> y = {1, 4, 2, 8, 5};
{"x", x}, {"y", y}, {"type", "scatter"}, {"mode", "lines+markers"}};
if (!args.headless) {
} else {
{"format", "png"},
{"width", 800},
{"height", 600},
{"filename", "hello_world"}
};
}
return 0;
}
auto parseGalleryArgs(int argc, char *argv[]) -> GalleryArgs
Parse command line arguments for gallery examples.
Definition arg_parser.cpp:4
auto main() -> int
Definition gallery_animate_sin_wave.cpp:48
std::vector< Object > Array
Definition plotly.hpp:27
nlohmann::json Object
Definition plotly.hpp:26
Public Plotly C++ API header.