TensorBoard
TensorFlow
axis labels
plot customization
data visualization

Does TensorBoard TensorFlow have the features to add labels for axes and legends on plots? If so, how?

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Introduction

TensorBoard can label runs and metric series through the data you log, but it is not a full plotting library like Matplotlib where you freely set axis titles, legends, and arbitrary chart decorations on built-in scalar charts. In practice, TensorBoard's default dashboards have limited plot customization, so the answer is partly yes for series naming and grouping, but mostly no for free-form axis and legend editing.

What TensorBoard Gives You By Default

TensorBoard's scalar dashboard is driven by what you log. If you write a scalar called loss, TensorBoard uses that tag name in the UI. If you compare multiple runs, the run names appear as the series labels.

Example logging code:

python
1import tensorflow as tf
2
3writer = tf.summary.create_file_writer("logs/run_1")
4
5with writer.as_default():
6    for step in range(5):
7        tf.summary.scalar("training/loss", 1.0 / (step + 1), step=step)
8        tf.summary.scalar("training/accuracy", 0.5 + step * 0.1, step=step)

In TensorBoard, the chart titles and series identifiers come from:

  • the summary tag such as training/loss
  • the run directory such as run_1

So you do get labels, but they come from the metadata of the logged summaries, not from a separate chart-formatting API.

Axis Labels Are Mostly Fixed In Built-In Plots

For the standard scalar dashboard, TensorBoard controls the axes itself. The horizontal axis is typically the training step, wall time, or relative time depending on the UI selection. The vertical axis reflects the scalar values.

What you cannot usually do on the built-in scalar plots is say:

  • label the x-axis as epoch number
  • label the y-axis as cross entropy loss
  • add a custom legend title
  • manually position annotations the way you would in Matplotlib

That kind of full chart customization is outside the normal built-in TensorBoard scalar feature set.

Use Metric Names And Run Names As Practical Labels

The most effective way to make TensorBoard charts readable is to log clean names.

Good example:

python
1import tensorflow as tf
2
3writer = tf.summary.create_file_writer("logs/adam_lr_1e3")
4
5with writer.as_default():
6    tf.summary.scalar("validation/f1_score", 0.81, step=1)

This produces a useful combination:

  • run label: adam_lr_1e3
  • chart tag: validation/f1_score

That is often the closest equivalent to choosing legend labels in ordinary plotting libraries.

If your run names and metric tags are descriptive, TensorBoard becomes much easier to interpret even without arbitrary axis-title editing.

Custom Scalars Can Improve Grouping, Not Full Styling

TensorBoard's custom scalars plugin can group existing scalar summaries into dashboards, which helps organization, but it still does not turn TensorBoard into a general-purpose plot styling tool.

Example:

python
1import tensorflow as tf
2from tensorboard.plugins.custom_scalar import layout_pb2
3
4writer = tf.summary.create_file_writer("logs/custom")
5
6layout = layout_pb2.Layout(category=[
7    layout_pb2.Category(
8        title="Metrics",
9        chart=[
10            layout_pb2.Chart(
11                title="Training Overview",
12                multiline=layout_pb2.MultilineChartContent(tag=["training/loss", "training/accuracy"])
13            )
14        ]
15    )
16])
17
18with writer.as_default():
19    tf.summary.experimental.write_raw_pb(layout.SerializeToString(), step=0)

This can help organize views, but it still does not give you arbitrary axis-title APIs like plt.xlabel() and plt.ylabel().

If You Need Full Labels, Log A Plot Image

When you need full control, the usual workaround is to create a Matplotlib or Plotly figure with custom labels and then log it as an image to TensorBoard.

python
1import io
2import matplotlib.pyplot as plt
3import tensorflow as tf
4
5figure = plt.figure()
6plt.plot([1, 2, 3], [0.9, 0.7, 0.4], label="loss")
7plt.xlabel("Epoch")
8plt.ylabel("Cross Entropy")
9plt.legend()
10
11buffer = io.BytesIO()
12plt.savefig(buffer, format="png")
13plt.close(figure)
14buffer.seek(0)
15image = tf.image.decode_png(buffer.getvalue(), channels=4)
16image = tf.expand_dims(image, 0)
17
18writer = tf.summary.create_file_writer("logs/plot_images")
19with writer.as_default():
20    tf.summary.image("labeled_plot", image, step=0)

This does not create an interactive scalar chart, but it does let you display fully labeled figures inside TensorBoard.

When You Need More Than TensorBoard Offers

TensorBoard is excellent for experiment tracking, metric comparison, embeddings, and graph inspection. It is not designed to replace a full scientific plotting environment.

If the main requirement is presentation-quality plotting with custom legends, annotations, and axes, a better workflow is often:

  1. use TensorBoard for experiment monitoring
  2. export or collect the metric values
  3. make final charts in Matplotlib, Seaborn, or Plotly

That division of labor keeps TensorBoard doing what it is best at.

Common Pitfalls

The biggest mistake is expecting the scalar plugin to expose a full plotting API. TensorBoard reads logged summaries; it is not a drop-in replacement for Matplotlib.

Another mistake is using unclear tag names such as metric1 or value. Because tag names become the visible labels, poor naming makes the charts harder to read.

People also confuse the presence of run labels with customizable legend controls. TensorBoard does show series identities, but the legend behavior is much more constrained than in dedicated plotting libraries.

Finally, if you need polished figures, do not fight the tool. Log a pre-rendered image or use a separate plotting stack for final presentation.

Summary

  • TensorBoard can show meaningful series labels through run names and summary tags.
  • Built-in scalar charts do not offer free-form axis-title and legend customization like Matplotlib.
  • Custom Scalars can improve grouping, but not full chart styling.
  • For full control over labels and legends, generate a plot externally and log it as an image.
  • Treat TensorBoard as an experiment-monitoring tool first, not a general-purpose plotting library.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design