Skip to content

Log custom x values for graph#

When logging metrics (or other series of values), you can set custom values for the x axis with the step argument.

run["metric"].append(
    value=acc,
    step=i,
)

Note

The entries logged for step must be strictly increasing Int or Float values.

How the step is incremented#

If the step argument is not provided, the step is automatically incremented on each append() call, in steps of 1.

This means that if you first log some custom step values in increments other than 1 and then continue logging values without the step argument, the step values will continue where they left off but in increments of 1.

Example

If you log step values at increments of 10:

for value,step in zip(range(10), range(0,100,10)):
    run["metric"].append(value=value, step=step)

the final step will be 90. If you then append more values, without providing a step:

for value in range(10):
    run["metric"].append(value=value)

the second set of step values will be logged in increments of 1 (starting from 91).

Chart showing a graph with values logged at varying step increments.

Logging images with custom index#

You might use the epoch number as the index for the append() method when logging a series of Matplotlib figures.

import neptune
import matplotlib.pyplot as plt

run = neptune.init_run()

for epoch in range(100):
    plt_fig = get_histogram()

    run["train/distribution"].append(
        plt_fig,
        step=epoch,
    )

Logging custom charts#

If you have customized charts with special values for the x axis, rather than logging the individual values as a series, you can create your own plot objects and upload those to Neptune.

Single static plot
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(7, 9))
run["matplotlib-fig"].upload(fig)
Single interactive plot
from neptune.types import File

fig = ...
run["visuals/matplotlib-fig"].upload(File.as_html(fig))