Skip to content

Fix figure issues - #320

Merged
jolaem merged 13 commits into
ccpem:developfrom
theredgeek:develop
Oct 7, 2026
Merged

jolaem merged 13 commits into
ccpem:developfrom
theredgeek:develop

Conversation

@theredgeek

Copy link
Copy Markdown
Contributor

Changed the logic for figure and font sizing

@jolaem
jolaem self-requested a review September 16, 2026 08:58
Refine plot sizing, typography, colorbars, image output, and pipeline test behavior.

@jolaem jolaem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I've added a few more changes that were breaking some other figures and moved your change to a general function. Do have a test and let me know if it works for you. if so I'll merge. Thanks!

jolaem added 9 commits October 7, 2026 15:43
The default axis tensor was created on the CPU, while the splat
renderer runs on `device`, which breaks GPU runs.
Compute class-averaged cosine similarity (mean and std) from per-class
sums of unit vectors, without building the N x N pairwise matrix.
Memory no longer grows quadratically with the number of samples.

A test checks the results against the full pairwise computation,
including classes absent from the data.
- Drop the tensorboard option, SummaryWriter and every writer argument
  to plot functions, and remove the tensorboard dependency.
- Add a vis_print option to render figures at 300 dpi for print, and
  document svg as a vis_format.
- Rename accuracy_plot to confusion_plot and log "Overall accuracy".
- Extract the shared _loss_curve_figure, _matrix_figure and
  _save_grid_figure helpers. Vector formats are embedded at native
  resolution.
Saving and layout
- Add save_figure as the single save path. Non-print rasters are
  capped at 720 px tall (top half of a 1440p screen); vis_print saves
  at 300 dpi and full size; image grids keep native resolution.
- Replace tight_layout with margins estimated from the tick labels the
  axes will draw, with equal outer padding on all sides. This avoids
  an extra text-layout pass.

Style
- Apply one rc style (_STYLE) to every plot through @_styled, and drop
  the scattered bold rc_context blocks.
- Use one title format for every epoch-based figure: "X at epoch N".
  Titles scale with the figure and shrink only when they would not fit.

Matrix plots
- Build matrix figures around a fixed-size image, so the matrix keeps
  its size and the padding is even.
- Draw the affinity and similarity matrices through one
  _similarity_figure helper, so they look identical. Remove the "Class
  Labels" axis labels and the ignored font_size and dpi parameters.
- Draw only the normalised confusion matrices; both CSVs are still
  written. Train and validation share a _confusion_figure helper.
- Write per-cell values only for MAX_ANNOTATED_CLASSES (25) classes or
  fewer. At 53 classes, N^2 text objects took about 14 s per call.

Embeddings
- Give t-SNE plots an 8:5 data area, matching the interactive
  embedding, with the legend outside the axes. Stop truncating legend
  labels to four characters and stop scaling markers with the class
  count.
Decode each latent/pose grid in a single decoder call instead of one
call per cell (21-36 GPU round trips per plot). Outputs match the
previous loops to within 1e-7.

interpolations_plot now interpolates poses from the four drawn class
representatives rather than the first four classes.
The affinity matrix is fixed input, so skip plotting it again when the
existing plot is newer than the CSV and was made with the same CSV
path, vis_print setting and selected classes, which are recorded in
plots/affinity_matrix_classes.txt.
The class-distribution histograms collected labels by iterating every
train, validation and test batch. That read, transformed and PNG-encoded
every image just to get its label, and sum(..., ()) made the collection
quadratic in the number of batches. Labels come from the file name, so
read them from the dataset paths instead. Histograms now count every
sample in each split, including the last partial training batch.
- Build t-SNE class masks once instead of rebuilding the label array
  for every class.
- Read the affinity CSV header once per path with a cached
  _affinity_classes helper, placed with the other private helpers.
- Warn and return instead of crashing in
  pose_class_disentanglement_plot (no poses) and
  latent_4enc_interpolate_plot (fewer than 4 classes), and accept
  suffix=None in confidence_plot.
- Remove unused locals.
Move the plotting, grid, mrc, colour, pose-interpolation and
similarity-matrix helpers out of utils into a new utils_vis module,
leaving as_list and latest_file in utils. A pure move with no
behaviour changes.
@jolaem
jolaem merged commit 7867135 into ccpem:develop Oct 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants