Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Add example to histogram colorbar on galleries#30107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
a49fac5
87e8e37
901cfa6
4df2b39
646be10
c81072f
19a2d19
9931dba
578e414
0089861
bf6f2e8
9c5c859
96781f3
6062d91
69a388f
b3d7b42
8004742
f3e8acf
cf4f62c
767ec0e
fdb37d4
31cf67d
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -17,15 +17,15 @@ | ||
delta = 0.025 | ||
x = y = np.arange(-3.0, 3.0, delta) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I zoomed this in a bit more to -2, +2, but not a big deal. | ||
X, Y = np.meshgrid(x, y) | ||
Z1 = np.exp(-((X+1)*1.3)**2 -((Y+1)*1.3)**2) | ||
Z2 =2.5*np.exp(-(X - 1)**2 - (Y - 1)**2) | ||
Z = (Z1**0.25 - Z2**0.5) | ||
# === Histogram from actual Z data === | ||
counts, bins = np.histogram(Z, bins=30) | ||
# === Colormap & Normalization === | ||
cmap = plt.get_cmap('RdYlBu_r') | ||
norm = mcolors.BoundaryNorm(bins, cmap.N) | ||
# === Main Plot === | ||
@@ -43,7 +43,7 @@ | ||
# === Plot Histogram === | ||
midpoints = bins[:-1] + np.diff(bins) / 2 | ||
bar_height = 1 / len(counts) | ||
cax.barh(midpoints, counts, height=np.median(np.diff(bins))*0.8, color=cmap(norm(midpoints))) | ||
Check failure on line 46 in galleries/examples/color/colorbar_histogram.py
| ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Note you need to fix these lines that are too long and the trailing whitespace error. | ||
# === Clean up === | ||
cax.spines[:].set_visible(False) | ||
@@ -52,7 +52,7 @@ | ||
# === Axis labels === | ||
cax.set_xlabel('Count', labelpad=10) | ||
cax.set_ylabel('Value', labelpad=6) | ||
Check failure on line 55 in galleries/examples/color/colorbar_histogram.py
| ||
# === Ticks === | ||
cax.set_yticks(bins) | ||
Uh oh!
There was an error while loading.Please reload this page.