Skip to content

fixed example axes_grid demo_axes_rgb.py figure 1 #6759

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions examples/axes_grid1/demo_axes_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,20 @@ def make_cube(r, g, b):
def demo_rgb():
fig, ax = plt.subplots()
ax_r, ax_g, ax_b = make_rgb_axes(ax, pad=0.02)
#fig.add_axes(ax_r)
#fig.add_axes(ax_g)
#fig.add_axes(ax_b)
# fig.add_axes(ax_r)
# fig.add_axes(ax_g)
# fig.add_axes(ax_b)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to leave these commented lines in?


r, g, b = get_rgb()
im_r, im_g, im_b, im_rgb = make_cube(r, g, b)
kwargs = dict(origin="lower", interpolation="nearest")

# make tickmarks invisible
ax.tick_params(length=0)
ax_r.tick_params(length=0)
ax_g.tick_params(length=0)
ax_b.tick_params(length=0)

ax.imshow(im_rgb, **kwargs)
ax_r.imshow(im_r, **kwargs)
ax_g.imshow(im_g, **kwargs)
Expand All @@ -58,22 +65,20 @@ def demo_rgb():
def demo_rgb2():
fig = plt.figure(2)
ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8], pad=0.0)
#fig.add_axes(ax)
#ax.add_RGB_to_figure()
# fig.add_axes(ax)
# ax.add_RGB_to_figure()

r, g, b = get_rgb()
kwargs = dict(origin="lower", interpolation="nearest")
ax.imshow_rgb(r, g, b, **kwargs)

ax.RGB.set_xlim(0., 9.5)
ax.RGB.set_xlim(0., 10.6)
ax.RGB.set_ylim(0.9, 10.6)

for ax1 in [ax.RGB, ax.R, ax.G, ax.B]:
for sp1 in ax1.spines.values():
sp1.set_color("w")
for tick in ax1.xaxis.get_major_ticks() + ax1.yaxis.get_major_ticks():
tick.tick1line.set_mec("w")
tick.tick2line.set_mec("w")
ax1.tick_params(axis='both', direction='in')
ax1.xaxis.set_ticks(np.arange(0, 12, 2))
ax1.yaxis.set_ticks(np.arange(0, 12, 2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can take the two tick-setters outside the loop and apply them to ax.RGB (or any one of the 4). There is no telling how long it will take before the underlying bug is found and fixed, so this is a reasonable workaround in the interim. In addition, once the bug is fixed, the automatically-located ticks will be based on the small ax.B so there will be fewer of them than you want.


return ax

Expand Down