MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_shared_axis_quantity

Function test_shared_axis_quantity

lib/matplotlib/tests/test_units.py:203–216  ·  view source on GitHub ↗
(quantity_converter)

Source from the content-addressed store, hash-verified

201
202
203def test_shared_axis_quantity(quantity_converter):
204 munits.registry[Quantity] = quantity_converter
205 x = Quantity(np.linspace(0, 1, 10), "hours")
206 y1 = Quantity(np.linspace(1, 2, 10), "feet")
207 y2 = Quantity(np.linspace(3, 4, 10), "feet")
208 fig, (ax1, ax2) = plt.subplots(2, 1, sharex='all', sharey='all')
209 ax1.plot(x, y1)
210 ax2.plot(x, y2)
211 assert ax1.xaxis.get_units() == ax2.xaxis.get_units() == "hours"
212 assert ax2.yaxis.get_units() == ax2.yaxis.get_units() == "feet"
213 ax1.xaxis.set_units("seconds")
214 ax2.yaxis.set_units("inches")
215 assert ax1.xaxis.get_units() == ax2.xaxis.get_units() == "seconds"
216 assert ax1.yaxis.get_units() == ax2.yaxis.get_units() == "inches"
217
218
219def test_shared_axis_datetime():

Callers

nothing calls this directly

Calls 5

QuantityClass · 0.85
get_unitsMethod · 0.80
set_unitsMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…