# How to scale properly my plot?

**URL:** <https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368>\
**Category:** Support & Discussions\
**Tags:** eeg, visualization\
**Created:** [August 14, 2023, 12:39pm UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368 "2023-08-14T12:39:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![annaprovorova](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/annaprovorova/32/2952_2.png) [@annaprovorova](https://mne.discourse.group/u/annaprovorova)\
**Post date:** [August 14, 2023, 12:39pm UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/1 "2023-08-14T12:39:48Z")

</div>

- MNE version: 1.4.2
- operating system: Windows 10

I load my data from edf format and do the following:

```python
import matplotlib.pyplot as plt
import mne

raw = mne.io.read_raw_edf(r'C:\Users\Анна\Desktop\EEG_Analysis\Irina_artifacts_test.edf', preload=True)
raw.crop(tmin=69.0, tmax=94.0).pick_types(meg="mag", eeg=True, emg=True, stim=True, eog=True)
raw.plot(scalings="auto")

```

The result is pretty messy:

 ![output](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/8/803ff7bbd42f3dc61cb752b528063737f6208c00.jpeg)

If I try to change scaligs, e.g.:

```python
raw.plot(scalings=dict(eeg='1e-6', emg='1e-6'))

```

The result looks worse:

 ![output2](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/0/09b700b6c068ada5fe6c2f01845fb3f236ab2898.png)

Please, help me, how can I change scalings?

---

<div class="post-metadata">

**Author:** ![scott-huberty](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/scott-huberty/32/2715_2.png) [@scott-huberty](https://mne.discourse.group/u/scott-huberty)\
**Post date:** [August 14, 2023, 2:32pm UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/2 "2023-08-14T14:32:01Z")

</div>

Hi @annaprovorova

what does the plot look like if you just do `raw.plot()` ?

According to [MNE documentation](https://mne.tools/stable/generated/mne.viz.plot_raw.html), the default scalings are

```python
dict(mag=1e-12, grad=4e-11, eeg=20e-6, eog=150e-6, ecg=5e-4,
     emg=1e-3, ref_meg=1e-12, misc=1e-3, stim=1,
     resp=1, chpi=1e-4, whitened=1e2)

```

`raw.plot()` uses the default scalings, which are pretty different from the custom scalings you passed in your code above. This might solve your problem.

---

<div class="post-metadata">

**Author:** ![annaprovorova](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/annaprovorova/32/2952_2.png) [@annaprovorova](https://mne.discourse.group/u/annaprovorova)\
**Post date:** [August 15, 2023, 5:43am UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/3 "2023-08-15T05:43:55Z")

</div>

Hi, @scott-huberty!  
Unfortunately, `raw.plot()` didn’t help. Result’s still the same:

 ![output3](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/4/475c8257a2d4c205ba32efc50460b692a4004d66.png)

---

<div class="post-metadata">

**Author:** ![wmvanvliet](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/wmvanvliet/32/100_2.png) [@wmvanvliet](https://mne.discourse.group/u/wmvanvliet)\
**Post date:** [August 15, 2023, 6:41am UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/4 "2023-08-15T06:41:54Z")

</div>

> [@annaprovorova](#):
>
> `raw.plot(scalings=dict(eeg='1e-6', emg='1e-6'))`

How about `raw.plot(scalings=dict(eeg='100e-6', emg='100e-6'))`? You can just try larger and larger scalings until you get the desired results. Also note that the `+` and `-` keys on your keyboard will make things larger/smaller if you have an interactive plot window (i.e. you are not plotting inline into a notebook).

---

<div class="post-metadata">

**Author:** ![annaprovorova](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/annaprovorova/32/2952_2.png) [@annaprovorova](https://mne.discourse.group/u/annaprovorova)\
**Post date:** [August 15, 2023, 11:06am UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/5 "2023-08-15T11:06:14Z")

</div>

Hi, @wmvanvliet !  
Thank you for your suggestion, but it doesn’t work ☹  
Result stay the same.

 ![output4](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/f/f153d6ab20b04d16443713f0f0c1ff36f8481343.png)

Could it be connected to the type of me file, .edf?

---

<div class="post-metadata">

**Author:** ![scott-huberty](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/scott-huberty/32/2715_2.png) [@scott-huberty](https://mne.discourse.group/u/scott-huberty)\
**Post date:** [August 15, 2023, 3:38pm UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/6 "2023-08-15T15:38:51Z")

</div>

Looking at the units displayed in the first plot you shared, the units are astronomical (It’s a little blurry but if I’m reading that number right it’s something like 30 billion microvolts?).

Thats’ very large! It’s hard to help more without more info. At this point I’m just grasping at straws, but Is this data you collected? You might need to look into how your data looks after acquisition, and before you save it to EDF.

 ![Screen Shot 2023-08-15 at 11.30.25 AM](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/8/81649be91bb334edfb20a40993a91ee57e175ed3.jpeg)

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [August 16, 2023, 8:07am UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/7 "2023-08-16T08:07:56Z")

</div>

The scaling issues comes from your dataset. MNE expects EEG signal in **Volts**. Typical EEG signal would then range around 40e-6 Volts. Thus, plotting with `raw.plot(scalings=dict(eeg=20e-6))` (default) yields. The best solution is for you to figure out which units the data is recorded in, and then apply a conversion:

```python
raw.apply_function(lambda x: x*1e-6, picks="eeg")

```

In the example above, the EEG data is scaled from microvolts to volts.  
You can also ignore this entirely and figure out a scaling which works for your dataset. The simplest way is to use `raw.plot()` interactively: press (or hold) the `-` key on your keyboard until the scale looks correct. See the `Help` button for all the keyboard shortcuts.

Mathieu

---

<div class="post-metadata">

**Author:** ![annaprovorova](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/annaprovorova/32/2952_2.png) [@annaprovorova](https://mne.discourse.group/u/annaprovorova)\
**Post date:** [September 6, 2023, 10:48am UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/8 "2023-09-06T10:48:20Z")

</div>

> [@scott-huberty](#):
>
> Looking at the units displayed in the first plot you shared, the units are astronomical (It’s a little blurry but if I’m reading that number right it’s something like 30 billion microvolts?).
> 
> Thats’ very large! It’s hard to help more without more info. At this point I’m just grasping at straws, but Is this data you collected? You might need to look into how your data looks after acquisition, and before you save it to EDF.

Hi @scott-huberty!  
Here is raw.info data. So frequency is just 500 Hz  
 ![image](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/e/ebd0084a989e7a5bcfb0fabbe1b7db7f14cae1bb.png)

Before saving it looked like normal… I have the same result if I try to plot any data from experiments.

Here is the data in edf format [Irina\_artifacts\_test.edf - Google Drive](https://drive.google.com/file/d/1QLf5JmPwe4m5X0I-mLk-pyijPbPIZWue/view?usp=sharing)

Sorry for long answer and thank you for help!

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [September 6, 2023, 4:26pm UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/9 "2023-09-06T16:26:02Z")

</div>

is it possible that your data were recorded in nanovolts?

```python
raw = mne.io.read_raw_edf("Irina_artifacts_test.edf")
raw.load_data()
raw.apply_function(lambda x: x * 1e-9)
raw.plot()

```

 ![nanovolts](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/3/377d961b922e1963bdfdbf1e2b479a8bca79b7cc.jpeg)

Note also that your `raw.info` says that your sampling rate was 500Hz and your highpass frequency was 1000Hz. That’s probably wrong (I don’t think MNE-Python will even allow a high-pass cutoff that is higher than the sampling frequency)

---

<div class="post-metadata">

**Author:** ![annaprovorova](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/annaprovorova/32/2952_2.png) [@annaprovorova](https://mne.discourse.group/u/annaprovorova)\
**Post date:** [September 7, 2023, 6:13am UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/10 "2023-09-07T06:13:07Z")

</div>

You are right. Data was in nanowolts, your solution helped!  
Thank you so much!!

---

<div class="post-metadata">

**Author:** ![xvliqing](https://avatars.discourse-cdn.com/v4/letter/x/e495f1/32.png) [@xvliqing](https://mne.discourse.group/u/xvliqing)\
**Post date:** [October 23, 2024, 5:22pm UTC](https://mne.discourse.group/t/how-to-scale-properly-my-plot/7368/11 "2024-10-23T17:22:50Z")

</div>

thank you, my problem is the same as annaprovorova Anna, adding this line can get the picture in mne similar to eeglab, my data is .bdf .
