scientific-visualization-book
scientific-visualization-book copied to clipboard
update transforms-hist.py to use parasite axes.
First of all, great book!
In "transforms-hist.py", using floating_axes is a bit cumbersome as you would already know (FWIW, I was the original author of axis_artist and axes_grid1 toolkit). My recommendation is to use parasite_axes with auxiliary transform (which defines the transform from the parasite_axes to the host_axes). Still, you need to create two additional axes, one to draw floating axis, another to draw histogram. However, I guess the logic is simpler and involves less math. For example, P2, P3 and P4 which were originally drawn in ax1, are now simply drawn using vlines
and fill_between
in the parasite_axes.
I understand that changing the code this way is not enough and the text also need to be changed. I just wanted to suggest an alternative solution.
For the question in the original comment at line 151,
# This auxiliary axis is necessary to draw stuff (no real idea why)
ax2_aux = ax2.get_aux_axes(transform)
axis_artist was originally designed to show images in the rectangular (pixel) coordinate and overlay the curvelinear coordinates upon them (mainly for astronomical images). So the transData of ax2 was meant to be the rectangular coordinate with which you can show images in their pixel coordinates. This could be confusing but this was the design decision I made at that time.
Anyhow, I think one can create another axes class (derived from floating_axes and/or parasite_axes) for use cases like this, which could be much easier to use. I may give it a try when I have more time.