TensorBoard
function plots
color customization
data visualization
tutorial

How to change colors of function plots in Tensorboard?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

TensorBoard does not generally give you a normal per-line API for choosing exact colors in scalar or function-like plots. In practice, line colors are assigned by TensorBoard's frontend, so the honest answer is that you usually cannot control them directly from SummaryWriter or from standard TensorFlow logging calls.

What You Can Control Easily

You can control:

  • run names
  • tag names
  • which data is grouped together

You usually cannot say:

  • "make this series red"
  • "make that series green"

with a stable built-in logging argument.

For example, standard scalar logging only lets you define the tag and value:

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

TensorBoard will display the series, but the actual color choice is handled by the UI.

Why People Think Naming Helps

Sometimes developers notice that changing run names or tag names changes the displayed colors. That happens because the frontend maps colors deterministically based on the displayed series set and ordering.

So while naming can influence which color ends up assigned, that is not the same as having a clean color-selection API. It is indirect and brittle.

For example:

python
1with tf.summary.create_file_writer("logs/experiment_blueish").as_default():
2    tf.summary.scalar("accuracy", 0.9, step=1)
3
4with tf.summary.create_file_writer("logs/experiment_other").as_default():
5    tf.summary.scalar("accuracy", 0.8, step=1)

The colors may differ, but you are not explicitly picking them. You are just changing the inputs that TensorBoard later hashes or orders.

What Actually Works in Practice

If your real goal is readability, these strategies usually help more than chasing exact color control:

  • use clear run names
  • log fewer overlapping series
  • compare small groups of runs at once
  • split unrelated metrics into separate tags

For example, this structure is often easier to read than dozens of similar tags inside one run:

python
1logs/
2  baseline/
3  lr_1e-3/
4  lr_1e-4/

That way the TensorBoard UI has a cleaner set of runs to visualize, even if you still cannot pick exact colors manually.

When You Truly Need Exact Colors

If exact color selection is a hard requirement, TensorBoard may not be the right final presentation tool. A better workflow is often:

  1. log training metrics normally
  2. export or read the event data
  3. produce a custom plot in Matplotlib, Plotly, or another charting library

Example with Matplotlib:

python
1import matplotlib.pyplot as plt
2
3steps = [0, 1, 2, 3]
4loss = [1.0, 0.8, 0.6, 0.5]
5
6plt.plot(steps, loss, color="crimson", label="loss")
7plt.legend()
8plt.show()

That gives you explicit visual control in a way TensorBoard's standard scalar dashboard generally does not.

Advanced Frontend Customization

Yes, it is possible to fork or patch TensorBoard's frontend code if you are willing to maintain a custom build. But that is not a normal experiment workflow, and it is rarely worth the maintenance cost just to force a palette.

For most teams, custom frontend modification is overkill compared with:

  • naming experiments well
  • reducing clutter
  • exporting data for publication-quality plots

Common Pitfalls

  • Assuming tf.summary or SummaryWriter exposes a direct color parameter for scalar series.
  • Mistaking indirect naming effects for a supported color customization API.
  • Overloading one dashboard with too many runs and then blaming color collisions alone.
  • Editing TensorBoard internals for a cosmetic need that would be easier to solve in another plotting library.
  • Expecting presentation-grade styling from a tool designed primarily for experiment inspection.

Summary

  • TensorBoard usually does not let you choose exact plot colors directly from logging code.
  • Colors are assigned by the frontend based on the displayed series.
  • Run names and tag structure can influence readability, but not through a stable explicit color API.
  • For exact palette control, export the data and plot it in a library such as Matplotlib.
  • TensorBoard is best treated as an experiment-inspection tool, not as a fully customizable chart-design tool.

Course illustration
Course illustration

All Rights Reserved.