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

Function test_integration_options

lib/matplotlib/tests/test_streamplot.py:104–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102
103@image_comparison(['streamplot_integration.png'], style='mpl20', tol=0.05)
104def test_integration_options():
105 # Linear potential flow over a lifting cylinder
106 n = 50
107 x, y = np.meshgrid(np.linspace(-2, 2, n), np.linspace(-3, 3, n))
108 th = np.arctan2(y, x)
109 r = np.sqrt(x**2 + y**2)
110 vr = -np.cos(th) / r**2
111 vt = -np.sin(th) / r**2 - 1 / r
112 vx = vr * np.cos(th) - vt * np.sin(th) + 1.0
113 vy = vr * np.sin(th) + vt * np.cos(th)
114
115 # Seed points
116 n_seed = 50
117 seed_pts = np.column_stack((np.full(n_seed, -1.75), np.linspace(-2, 2, n_seed)))
118
119 fig, axs = plt.subplots(3, 1, figsize=(6, 14))
120 th_circ = np.linspace(0, 2 * np.pi, 100)
121 for ax, max_val in zip(axs, [0.05, 1, 5]):
122 ax_ins = ax.inset_axes([0.0, 0.7, 0.3, 0.35])
123 for ax_curr, is_inset in zip([ax, ax_ins], [False, True]):
124 ax_curr.streamplot(
125 x,
126 y,
127 vx,
128 vy,
129 start_points=seed_pts,
130 broken_streamlines=False,
131 arrowsize=1e-10,
132 linewidth=2 if is_inset else 0.6,
133 color="k",
134 integration_max_step_scale=max_val,
135 integration_max_error_scale=max_val,
136 )
137
138 # Draw the cylinder
139 ax_curr.fill(
140 np.cos(th_circ),
141 np.sin(th_circ),
142 color="w",
143 ec="k",
144 lw=6 if is_inset else 2,
145 )
146
147 # Set axis properties
148 ax_curr.set_aspect("equal")
149
150 # Set axis limits and show zoomed region
151 ax_ins.set_xlim(-1.2, -0.7)
152 ax_ins.set_ylim(-0.8, -0.4)
153 ax_ins.set_yticks(())
154 ax_ins.set_xticks(())
155
156 ax.set_ylim(-1.5, 1.5)
157 ax.axis("off")
158 ax.indicate_inset_zoom(ax_ins, ec="k")
159
160 fig.tight_layout()
161

Callers

nothing calls this directly

Calls 12

sqrtMethod · 0.80
inset_axesMethod · 0.80
set_yticksMethod · 0.80
set_xticksMethod · 0.80
indicate_inset_zoomMethod · 0.80
subplotsMethod · 0.45
fillMethod · 0.45
set_aspectMethod · 0.45
set_xlimMethod · 0.45
set_ylimMethod · 0.45
axisMethod · 0.45
tight_layoutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…