Results
Data visualization panel with plots, charts, images, and tables
Overview#
The Results panel provides a comprehensive data visualization API for creating plots, charts, images, and tables. Results are sent from Python via WebSocket and displayed in real-time with version control, tagging, and interactive viewing features.
Quick Start#
from witwin import Results
import numpy as np
# Create a simple line plot
x = np.linspace(0, 10, 100)
y = np.sin(x)
Results.plot(x, y, title="Sine Wave")
# Commit to save the results
Results.commit(message="My first plot")API Reference#
Basic Plot Types#
from witwin import Results
# Line plot
Results.plot(x, y, title=None, xlabel=None, ylabel=None)
# Bar chart
Results.bar(categories, values, title=None)
# Scatter plot
Results.scatter(x, y, title=None)
# Heatmap/Image
Results.imshow(data, title=None, cmap=None)
# Data table
Results.table(data_dict, title=None)Statistical Plot Types#
# Histogram
Results.hist(data, bins=30, title=None)
# Pie chart
Results.pie(values, labels, title=None)
# Box plot
Results.boxplot(data, title=None)Advanced Plot Types#
# Area chart
Results.area(x, y, title=None)
# Radar chart
Results.radar(values, labels, title=None)
# 3D Surface plot
Results.surface(x, y, z, title=None)
# Contour plot
Results.contour(x, y, z, title=None)
# Error bar plot
Results.errorbar(x, y, yerr=None, xerr=None, title=None)
# Stem plot
Results.stem(x, y, title=None)
# Polar plot
Results.polar(theta, r, title=None)
# Text display
Results.text(text, title=None)Utility Methods#
# Clear pending plots
Results.clear()
# Commit results to version history
Results.commit(message=None, tag=None, tag_color=None)
# Delete a specific version
Results.delete_version(version_id)
# Get all version history
Results.get_all_versions()Plot Examples#
Line Plot#
from witwin import Results
import numpy as np
x = np.linspace(0, 10, 100)
y = np.sin(x)
Results.plot(x, y, title="Sine Wave", xlabel="Time", ylabel="Amplitude")
Results.commit()Bar Chart#
categories = ['Model A', 'Model B', 'Model C', 'Model D']
values = [0.945, 0.923, 0.887, 0.912]
Results.bar(categories, values, title="Model Accuracy Comparison")
Results.commit()Scatter Plot#
x = np.random.randn(100)
y = 2 * x + np.random.randn(100) * 0.5
Results.scatter(x, y, title="Linear Correlation")
Results.commit()Heatmap/Image#
# 2D data as heatmap
data = np.random.randn(20, 30)
Results.imshow(data, title="2D Field Distribution")
# RGB image (H x W x 3)
image = np.random.rand(100, 100, 3) * 255
Results.imshow(image.astype(np.uint8), title="RGB Image")
Results.commit()Data Table#
table_data = {
'Model': ['ResNet', 'VGG', 'MobileNet'],
'Accuracy': [0.945, 0.923, 0.887],
'Latency (ms)': [32, 28, 45]
}
Results.table(table_data, title="Model Comparison")
Results.commit()Histogram#
data = np.random.randn(1000)
Results.hist(data, bins=50, title="Normal Distribution")
Results.commit()Pie Chart#
values = [35, 25, 20, 20]
labels = ['Category A', 'Category B', 'Category C', 'Category D']
Results.pie(values, labels, title="Distribution")
Results.commit()Box Plot#
data = [np.random.randn(100) + i for i in range(4)]
Results.boxplot(data, title="Distribution Comparison")
Results.commit()Radar Chart#
values = [0.9, 0.7, 0.8, 0.6, 0.85]
labels = ['Accuracy', 'Speed', 'Memory', 'Latency', 'Throughput']
Results.radar(values, labels, title="Model Performance")
Results.commit()Error Bar Plot#
x = np.arange(5)
y = [2.3, 4.5, 3.2, 5.1, 4.8]
yerr = [0.3, 0.5, 0.2, 0.4, 0.3]
Results.errorbar(x, y, yerr=yerr, title="Measurements with Error")
Results.commit()Polar Plot#
theta = np.linspace(0, 2 * np.pi, 100)
r = 1 + np.cos(theta)
Results.polar(theta, r, title="Polar Pattern")
Results.commit()Version Management#
Commit System#
# Simple commit (creates auto-incrementing version number)
Results.commit()
# Commit with message
Results.commit(message="Baseline Results")
# Commit with tag and custom color
Results.commit(
message="Best Model - Epoch 50",
tag="best",
tag_color="#00ff00"
)Version History Features#
- Persistent: Survives page refresh and reconnection
- Ordering: Reverse chronological (newest first)
- Deletable: Delete versions with confirmation
- Tag Colors: Auto-generated or custom hex colors
Tag System#
Tags provide visual categorization with automatic or custom colors:
| Tag | Use Case |
|---|---|
train | Training results |
val | Validation results |
test | Test results |
baseline | Baseline comparison |
best | Best performing model |
exp | Experimental results |
# Auto color from tag name
Results.commit(tag="train")
# Custom color
Results.commit(tag="best", tag_color="#00ff00")Data Type Support#
The Results API automatically converts common data types:
| Input Type | Conversion |
|---|---|
| PyTorch Tensor | → Python list |
| NumPy Array | → Python list |
| Pandas DataFrame | → Dict format |
| Python list/tuple | Direct use |
Example with Different Types#
import torch
import numpy as np
# PyTorch tensors (auto-converted)
x = torch.linspace(0, 10, 100)
y = torch.sin(x)
Results.plot(x, y, title="PyTorch Data")
# NumPy arrays (auto-converted)
x = np.linspace(0, 10, 100)
y = np.sin(x)
Results.plot(x, y, title="NumPy Data")
Results.commit()Usage Workflows#
Machine Learning Training#
from witwin import Results
for epoch in range(epochs):
train_loss = train_one_epoch()
val_loss = validate()
# Clear previous plots
Results.clear()
# Plot training curves
Results.plot(train_losses, title="Training Loss")
Results.plot(val_losses, title="Validation Loss")
# Show metrics
Results.bar(['Accuracy', 'Precision', 'Recall', 'F1'],
[acc, prec, recall, f1], title="Metrics")
# Commit with epoch tag
Results.commit(
message=f"Epoch {epoch+1}/{epochs}",
tag="train"
)Data Analysis#
from witwin import Results
# Distribution analysis
Results.scatter(data.x, data.y, title="Data Distribution")
Results.hist(data.values, title="Value Histogram")
# Correlation heatmap
Results.imshow(correlation_matrix, title="Correlation Matrix")
# Summary statistics
Results.table(stats_dict, title="Summary Statistics")
Results.commit(message="Data Analysis", tag="analysis")Comparing Models#
from witwin import Results
for model_name, model in models.items():
predictions = model.predict(test_data)
metrics = evaluate(predictions, test_labels)
Results.clear()
Results.bar(list(metrics.keys()), list(metrics.values()),
title=f"{model_name} Performance")
Results.commit(message=model_name, tag=model_name.lower())Frontend Features#
Panel UI#
- Version Sidebar: List of all committed versions with tags
- Plot Area: Flexible grid layout for multiple plots
- Size Slider: Adjust plot size (50%-200%)
- Fullscreen Mode: Expand panel to full window
Performance Guidelines#
| Limit | Recommended |
|---|---|
| Plots per version | ~50 plots |
| Data points per plot | ~10,000 points |
| Version history | Unlimited |