|
| 1 | +import sys |
| 2 | + |
1 | 3 | import numpy as np |
2 | 4 | import matplotlib.pyplot as plt |
3 | 5 | from matplotlib.testing.decorators import check_figures_equal |
@@ -240,3 +242,77 @@ def test_stop_viewing(fig_test, fig_ref): |
240 | 242 |
|
241 | 243 | ax1_ref.plot(data) |
242 | 244 | ax1_ref.text(0.5, 0.5, "Hello") |
| 245 | + |
| 246 | + |
| 247 | +# On MacOS the results are off by an extremely tiny amount, can't even see in diff. It's close enough... |
| 248 | +@check_figures_equal(tol=0.02 if sys.platform.startswith("darwin") else 0) |
| 249 | +def test_log_line(fig_test, fig_ref): |
| 250 | + data = [i for i in range(1, 10)] |
| 251 | + |
| 252 | + # Test case... Create a view and stop it... |
| 253 | + ax1_test, ax2_test = fig_test.subplots(1, 2) |
| 254 | + |
| 255 | + ax1_test.set(xscale="log", yscale="log") |
| 256 | + ax1_test.plot(data, "-o") |
| 257 | + |
| 258 | + view(ax2_test, ax1_test, scale_lines=False) |
| 259 | + ax2_test.set_xlim(-1, 10) |
| 260 | + ax2_test.set_ylim(-1, 10) |
| 261 | + |
| 262 | + # Reference, just don't plot anything at all in the second axes... |
| 263 | + ax1_ref, ax2_ref = fig_ref.subplots(1, 2) |
| 264 | + |
| 265 | + ax1_ref.set(xscale="log", yscale="log") |
| 266 | + ax1_ref.plot(data, "-o") |
| 267 | + ax2_ref.plot(data, "-o") |
| 268 | + ax2_ref.set_xlim(-1, 10) |
| 269 | + ax2_ref.set_ylim(-1, 10) |
| 270 | + |
| 271 | + |
| 272 | +@check_figures_equal() |
| 273 | +def test_log_scatter(fig_test, fig_ref): |
| 274 | + data = [i for i in range(1, 11)] |
| 275 | + |
| 276 | + # Test case... Create a view and stop it... |
| 277 | + ax1_test, ax2_test = fig_test.subplots(1, 2) |
| 278 | + |
| 279 | + ax1_test.set(xscale="log", yscale="log") |
| 280 | + ax1_test.scatter(data, data) |
| 281 | + |
| 282 | + view(ax2_test, ax1_test, scale_lines=False) |
| 283 | + ax2_test.set_xlim(-5, 15) |
| 284 | + ax2_test.set_ylim(-5, 15) |
| 285 | + |
| 286 | + # Reference, just don't plot anything at all in the second axes... |
| 287 | + ax1_ref, ax2_ref = fig_ref.subplots(1, 2) |
| 288 | + |
| 289 | + ax1_ref.set(xscale="log", yscale="log") |
| 290 | + ax1_ref.scatter(data, data) |
| 291 | + ax2_ref.scatter(data, data) |
| 292 | + ax2_ref.set_xlim(-5, 15) |
| 293 | + ax2_ref.set_ylim(-5, 15) |
| 294 | + |
| 295 | + |
| 296 | +@check_figures_equal() |
| 297 | +def test_log_scatter_with_colors(fig_test, fig_ref): |
| 298 | + data = [i for i in range(1, 11)] |
| 299 | + colors = list("rgbrgbrgbr") |
| 300 | + |
| 301 | + # Test case... Create a view and stop it... |
| 302 | + ax1_test, ax2_test = fig_test.subplots(1, 2) |
| 303 | + |
| 304 | + ax1_test.set(xscale="log", yscale="log") |
| 305 | + ax1_test.scatter(data, data, color=colors) |
| 306 | + |
| 307 | + view(ax2_test, ax1_test, scale_lines=False) |
| 308 | + ax2_test.set_xlim(-5, 15) |
| 309 | + ax2_test.set_ylim(-5, 15) |
| 310 | + |
| 311 | + # Reference, just don't plot anything at all in the second axes... |
| 312 | + ax1_ref, ax2_ref = fig_ref.subplots(1, 2) |
| 313 | + |
| 314 | + ax1_ref.set(xscale="log", yscale="log") |
| 315 | + ax1_ref.scatter(data, data, color=colors) |
| 316 | + ax2_ref.scatter(data, data, color=colors) |
| 317 | + ax2_ref.set_xlim(-5, 15) |
| 318 | + ax2_ref.set_ylim(-5, 15) |
0 commit comments