How do I retrieve the colorbar vlim when plotting topomaps for a Spectrum object?

I’m trying to create the topomaps of multiple Spectrum objects using Specrtum.plot_topomap, and I would like to have all these topomaps share the same vlim as one of them. Therefore, I need to retrieve the vlim from the Figure object returned by Specrtum.plot_topomap. How do I do this? Thanks!

You could probe each object in the Figure object for whether it has a colorbar, and then get a list of all colorbars. Then, for each colorbar you check the limits.

See here for a start: python - Retrieve all colorbars in figure - Stack Overflow

1 Like

Assuming that Spectrum.plot_topomap returns a Figure object, you can typically access the color scaling parameters (including vlim) from the returned Axes object. Here’s a general example:

Assuming Spectrum.plot_topomap returns a Figure object

fig = Spectrum.plot_topomap()

Assuming the topomap is the first Axes in the Figure

axes = fig.get_axes()[0]

Accessing vlim from the Axes

vlim = axes.get_vlim()

Now you can use vlim as needed

print(“vlim:”, vlim)

1 Like