# Mne.viz.plot\_topomap and color bar

**URL:** <https://mne.discourse.group/t/mne-viz-plot-topomap-and-color-bar/3141>\
**Category:** Support & Discussions\
**Created:** [May 15, 2021, 12:03pm UTC](https://mne.discourse.group/t/mne-viz-plot-topomap-and-color-bar/3141 "2021-05-15T12:03:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkkubins](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mkkubins/32/717_2.png) [@mkkubins](https://mne.discourse.group/u/mkkubins)\
**Post date:** [May 15, 2021, 12:03pm UTC](https://mne.discourse.group/t/mne-viz-plot-topomap-and-color-bar/3141/1 "2021-05-15T12:03:06Z")

</div>

- MNE-Python version: 0.23.dev0
- operating system: Windows

Hi,  
I have a question is it possible to add a color bar to mne.vix.plot\_topomap? I am a bit struggle with this because every time when I am using fig.colorbar(im, ax=ax, shrink=0.6) it shows an error. I would like to add one color bar for all subplots.

Thanks

```python
fig, ax = plt.subplots(nrows=1,ncols=4, figsize=(20, 10),sharex=True, sharey=True)
mne.viz.plot_topomap(delta_baseline[0],place,names=chs,show_names=True,cmap='coolwarm',axes=ax[0])
mne.viz.plot_topomap(delta_x[0],place,names=chs,show_names=True,cmap='coolwarm',axes=ax[1])
mne.viz.plot_topomap(delta_y[0],place,names=chs,show_names=True,cmap='coolwarm',axes=ax[2])
mne.viz.plot_topomap(delta_z[0],place,names=chs,show_names=True,cmap='coolwarm',axes=ax[3])
ax[0].set_title('Baseline',fontweight='bold')
ax[1].set_title('x', fontweight='bold')
ax[2].set_title('y', fontweight='bold')
ax[3].set_title('z', fontweight='bold')
fig.suptitle('Delta',x=0.1,y=0.53,fontweight='bold')

```

---

<div class="post-metadata">

**Author:** ![Awol](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@Awol](https://mne.discourse.group/u/Awol)\
**Post date:** [May 15, 2021, 7:06pm UTC](https://mne.discourse.group/t/mne-viz-plot-topomap-and-color-bar/3141/2 "2021-05-15T19:06:41Z")

</div>

I have exactly the same question!! How to add a colorbar with mne.vix.plot\_topomap on non-evoked/raw data !!  
Thank you!

---

<div class="post-metadata">

**Author:** ![Marc](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/marc/32/154_2.png) [@Marc](https://mne.discourse.group/u/Marc)\
**Post date:** [May 17, 2021, 8:02am UTC](https://mne.discourse.group/t/mne-viz-plot-topomap-and-color-bar/3141/3 "2021-05-17T08:02:10Z")

</div>

Does this help you? To compare multiple topomaps, I provide vmin and vmax. Then you can refer to any topomap for the creation of the colorbar.

```
fig,(ax1,ax2) = plt.subplots(ncols=2)
im,cm = mne.viz.plot_topomap(x1, info, axes=ax1,show=False,vmin=vmin,vmax=vmax)   
im,cm = mne.viz.plot_topomap(x2, info, axes=ax2,show=False,vmin=vmin,vmax=vmax)   
# manually fiddle the position of colorbar
ax_x_start = 0.95
ax_x_width = 0.04
ax_y_start = 0.1
ax_y_height = 0.9
cbar_ax = fig.add_axes([ax_x_start, ax_y_start, ax_x_width, ax_y_height])
clb = fig.colorbar(im, cax=cbar_ax)
clb.ax.set_title(unit_label,fontsize=fontsize) # title on top of colorbar

```

This approach is tedious, but also very flexible. (Code not tested.)

---

<div class="post-metadata">

**Author:** ![mkkubins](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mkkubins/32/717_2.png) [@mkkubins](https://mne.discourse.group/u/mkkubins)\
**Post date:** [May 17, 2021, 10:46am UTC](https://mne.discourse.group/t/mne-viz-plot-topomap-and-color-bar/3141/4 "2021-05-17T10:46:26Z")

</div>

> [@Marc](#):
>
> ```python
> fig,(ax1,ax2) = plt.subplots(ncols=2)
> im,cm = mne.viz.plot_topomap(x1, info, axes=ax1,show=False,vmin=vmin,vmax=vmax)   
> im,cm = mne.viz.plot_topomap(x2, info, axes=ax2,show=False,vmin=vmin,vmax=vmax)   
> # manually fiddle the position of colorbar
> ax_x_start = 0.95
> ax_x_width = 0.04
> ax_y_start = 0.1
> ax_y_height = 0.9
> cbar_ax = fig.add_axes([ax_x_start, ax_y_start, ax_x_width, ax_y_height])
> clb = fig.colorbar(im, cax=cbar_ax)
> clb.ax.set_title(unit_label,fontsize=fontsize) # title on top of colorbar
> 
> ```

Yes, it’s working!! thank you so much for the help! 🙂

---

<div class="post-metadata">

**Author:** ![youssif9595](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/youssif9595/32/1776_2.png) [@youssif9595](https://mne.discourse.group/u/youssif9595)\
**Post date:** [July 26, 2022, 11:31am UTC](https://mne.discourse.group/t/mne-viz-plot-topomap-and-color-bar/3141/5 "2022-07-26T11:31:50Z")

</div>

it worked fine for me too thank you

---

<div class="post-metadata">

**Author:** ![stewie](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@stewie](https://mne.discourse.group/u/stewie)\
**Post date:** [June 15, 2023, 4:40pm UTC](https://mne.discourse.group/t/mne-viz-plot-topomap-and-color-bar/3141/6 "2023-06-15T16:40:37Z")

</div>

Is there a similar option to do this for mne.viz.plot\_evoked\_topomap?

I am trying but cannot figure it out. I will create a new post for this
