MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / plot_set_series_label

Function plot_set_series_label

plot/plot.c:1462–1485  ·  view source on GitHub ↗

* @brief Replace the legend label of the series at @p index. * * Allocates a deep copy of @p label first; only when that succeeds is * the previous label freed and replaced. Passing NULL is a valid way * to clear the label entirely — the series will render in the legend * as `(series)` until a fresh label is set. * * Ownership semantics: the caller may free its copy of @p label * immediate

Source from the content-addressed store, hash-verified

1460 PLOT_LOG("[plot_add_bar]: enter (plot=%p, n=%zu, label=%s)", (void*)plot, n, label ? label : "(null)");
1461 return plot_add_series(plot, NULL, y, n, label, PLTYPE_BAR, color);
1462}
1463
1464
1465/**
1466 * @brief Read back the legend label of the series at @p index.
1467 *
1468 * Returns a pointer to the series' internal label string. The pointer
1469 * is borrowed: the plot retains ownership and the caller must not free
1470 * it. The string remains valid only until the next operation that may
1471 * relocate or destroy the label — concretely plot_set_series_label(),
1472 * plot_remove_series(), plot_clear_series(), or plot_destroy().
1473 *
1474 * @param plot Plot to query. May be NULL.
1475 * @param index Zero-based series index.
1476 *
1477 * @return Borrowed pointer to the label, or NULL when @p plot is NULL,
1478 * @p index is out of range, or the series was added with a
1479 * NULL label.
1480 *
1481 * @code
1482 * const char* lbl = plot_get_series_label(plot, 0);
1483 * printf("first series: %s\n", lbl ? lbl : "<unlabeled>");
1484 * @endcode
1485 */
1486const char* plot_get_series_label(const Plot* plot, size_t index) {
1487 PLOT_LOG("[plot_get_series_label]: enter (plot=%p, index=%zu)", (const void*)plot, index);
1488 if (!plot || index >= plot->seriesCount) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected