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

Function test_custom_fmt_data

lib/matplotlib/tests/test_polar.py:473–497  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

471
472
473def 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')

Callers

nothing calls this directly

Calls 1

format_coordMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…