Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 476b1e6

Browse files
authored
Merge pull request #26352 from anntzer/meh
Fix bad histogramming bins in mri/eeg example.
2 parents f08ff36 + 1d38f70 commit 476b1e6

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

galleries/examples/specialty_plots/mri_with_eeg.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import matplotlib.cbook as cbook
1414
import matplotlib.cm as cm
1515
from matplotlib.collections import LineCollection
16-
from matplotlib.ticker import MultipleLocator
1716

1817
fig = plt.figure("MRI_with_EEG")
1918

@@ -28,15 +27,10 @@
2827

2928
# Plot the histogram of MRI intensity
3029
ax1 = fig.add_subplot(2, 2, 2)
31-
im = np.ravel(im)
32-
im = im[np.nonzero(im)] # Ignore the background
33-
im = im / (2**16 - 1) # Normalize
34-
ax1.hist(im, bins=100)
35-
ax1.xaxis.set_major_locator(MultipleLocator(0.4))
30+
im = im[im.nonzero()] # Ignore the background
31+
ax1.hist(im, bins=np.arange(0, 2**16+1, 512))
32+
ax1.set(xlabel='Intensity (a.u.)', ylabel='MRI density', yticks=[])
3633
ax1.minorticks_on()
37-
ax1.set_yticks([])
38-
ax1.set_xlabel('Intensity (a.u.)')
39-
ax1.set_ylabel('MRI density')
4034

4135
# Load the EEG data
4236
n_samples, n_rows = 800, 4
@@ -72,6 +66,5 @@
7266

7367
ax2.set_xlabel('Time (s)')
7468

75-
7669
plt.tight_layout()
7770
plt.show()

0 commit comments

Comments
 (0)