Skip to main content

Live plotting utility for RL environments (Gym, Stable-Baselines, etc.)

Project description

gym-plotter

A lightweight live plotting utility for RL training (works with Gym, Stable-Baselines or custom loops).
Plots raw + smoothed rewards, loss and other metrics in real-time.

Features

  • Live plotting during training
  • Raw and smoothed (moving average) metrics
  • Best score marker
  • Training stats box (latest reward, avg reward)
  • Auto-save final plot

Installation

pip install gym-plotter


## Usage
import gymnasium as gym
from gym_plotter import RLPlotter

# Initialize environment and live plotter
env = gym.make("CartPole-v1")
plotter = RLPlotter()

for episode in range(50):
    state, _ = env.reset()
    done = False
    total_reward = 0
    loss = 0  # Replace with your actual loss calculation

    while not done:
        action = env.action_space.sample()  # Replace with your policy action
        state, reward, terminated, truncated, info = env.step(action)
        done = terminated or truncated
        total_reward += reward

    # Log metrics after each episode
    plotter.log(reward=total_reward, loss=loss)

# Save final plot to file
plotter.save("training_plot.png")
env.close()
# Example Output

gym-plotter displays training progress in real time.
Each metric (reward, loss, etc.) appears as both raw and smoothed curves, with the best reward highlighted and a live stats box summarizing performance.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gym_plotter-0.1.1.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gym_plotter-0.1.1-py3-none-any.whl (1.9 kB view details)

Uploaded Python 3

File details

Details for the file gym_plotter-0.1.1.tar.gz.

File metadata

  • Download URL: gym_plotter-0.1.1.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for gym_plotter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8821f1f27719d79cc33914425e44eca057b016c98ab2d4105e680c1633076115
MD5 6e1cf5d32dae43b418bf93840cc1847e
BLAKE2b-256 344b1895739d8fb961f47e36540aab3096317dbf7c58b22fe772dcafde2dec43

See more details on using hashes here.

File details

Details for the file gym_plotter-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gym_plotter-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 1.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for gym_plotter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53374e3677c57859fefa0fe33758b84915af3c125a035b07c31cf5696f694fd8
MD5 b6a179a9360c23bd0d53af8019b49f24
BLAKE2b-256 2cc30258254df163bc69dfbc13925b011d3b30b14c5455cf8ef2a816914a4346

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page