()
| 471 | |
| 472 | |
| 473 | def test_custom_fmt_data(): |
| 474 | ax = plt.subplot(projection="polar") |
| 475 | def millions(x): |
| 476 | return '$%1.1fM' % (x*1e-6) |
| 477 | |
| 478 | # Test only x formatter |
| 479 | ax.fmt_xdata = None |
| 480 | ax.fmt_ydata = millions |
| 481 | assert ax.format_coord(12, 2e7) == "θ=3.8197186342π (687.54935416°), r=$20.0M" |
| 482 | assert ax.format_coord(1234, 2e6) == "θ=392.794399551π (70702.9919191°), r=$2.0M" |
| 483 | assert ax.format_coord(3, 100) == "θ=0.95493π (171.887°), r=$0.0M" |
| 484 | |
| 485 | # Test only y formatter |
| 486 | ax.fmt_xdata = millions |
| 487 | ax.fmt_ydata = None |
| 488 | assert ax.format_coord(2e5, 1) == "θ=$0.2M, r=1.000" |
| 489 | assert ax.format_coord(1, .1) == "θ=$0.0M, r=0.100" |
| 490 | assert ax.format_coord(1e6, 0.005) == "θ=$1.0M, r=0.005" |
| 491 | |
| 492 | # Test both x and y formatters |
| 493 | ax.fmt_xdata = millions |
| 494 | ax.fmt_ydata = millions |
| 495 | assert ax.format_coord(2e6, 2e4*3e5) == "θ=$2.0M, r=$6000.0M" |
| 496 | assert ax.format_coord(1e18, 12891328123) == "θ=$1000000000000.0M, r=$12891.3M" |
| 497 | assert ax.format_coord(63**7, 1081968*1024) == "θ=$3938980.6M, r=$1107.9M" |
| 498 | |
| 499 | |
| 500 | @image_comparison(['polar_log.png'], style='default') |
nothing calls this directly
no test coverage detected
searching dependent graphs…