Skip to content

Positioning floating_axes.FloatingSubplot #19832

Closed
@w2naf

Description

@w2naf

Bug report

Bug summary

In a previous version of matplotlib, I was able to reposition and stretch a curvilinear coordinate axis created with floating_axes.FloatingSubplot after the axis has been created using Dividers and ax.set_axes_locator(). Now in matplotlib version 3.3.4 I can only get the axis to translate, but not stretch.

Code for reproduction

#!/usr/bin/env python3
from matplotlib import pyplot as plt
from matplotlib.transforms import Affine2D, Transform
import mpl_toolkits.axisartist.floating_axes as floating_axes
from matplotlib.projections import polar
from mpl_toolkits.axisartist.grid_finder import FixedLocator, DictFormatter
import mpl_toolkits.axes_grid1.axes_size as Size
from mpl_toolkits.axes_grid1 import Divider

fig = plt.figure()

# Generate first axis using normal methods.
ax0 = fig.add_subplot(111)
ax0.set_xticks([0,500,1000,1500,2000])

# Generate a curvilear axis for the second axis.
angle_ticks     = [(0, '0'), (0.079, '500'), (0.157, '1000'), (0.235, '1500'), (0.314, '2000')]
grid_locator1   = FixedLocator([v for v, s in angle_ticks])
tick_formatter1 = DictFormatter(dict(angle_ticks))

alt_ticks       = [(6371.0, '0'), (6671.0, '300'), (6971.0, '600'), (7271.0, '900'), (7571.0, '1200')]
grid_locator2   = FixedLocator([v for v, s in alt_ticks])
tick_formatter2 = DictFormatter(dict(alt_ticks))

tr_rotate       = Affine2D().rotate(1.414)
tr_shift        = Affine2D().translate(0, 6371)
tr              = polar.PolarTransform() + tr_rotate

grid_helper = \
    floating_axes.GridHelperCurveLinear(tr, extremes=(0, 0.314, 6371, 7871),
                                        grid_locator1=grid_locator1,
                                        grid_locator2=grid_locator2,
                                        tick_formatter1=tick_formatter1,
                                        tick_formatter2=tick_formatter2,)

ax1 = floating_axes.FloatingSubplot(fig, 111, grid_helper=grid_helper)
ax1.invert_xaxis()
fig.add_subplot(ax1, transform=tr)

horiz   = [Size.Scaled(1.0)]
vert    = [Size.Scaled(1.0)]
ax0_div = Divider(fig,[0.0, 0.5, 1.0, 0.45],horiz,vert,aspect=False) # Rectangular Coordinates
ax1_div = Divider(fig,[0.0, 0.0, 1.0, 0.45],horiz,vert,aspect=False) # Curvilinear Coordinates

ax0_loc = ax0_div.new_locator(nx=0,ny=0) # Rectangular Coordinates
ax1_loc = ax1_div.new_locator(nx=0,ny=0) # Curvilinear Coordinates

ax0.set_axes_locator(ax0_loc) # Rectangular Coordinates
ax1.set_axes_locator(ax1_loc) # Curvilinear Coordinates

fig.savefig('bug_report.png',bbox_inches='tight')

Actual outcome

bug_report

Expected outcome

I expected to be able to stretch the curvilinear coordinate system so that its x-axis is aligned with the rectangular coordinate system.

Matplotlib version

  • Operating system: Ubuntu 18.04 LTS
  • Matplotlib version: 3.3.4
  • Matplotlib backend: Qt5Agg
  • Python version: 3.7.7 (default, May 7 2020, 21:25:33) [GCC 7.3.0]

Matplotlib installed with anacond default linux installer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions