diff --git a/figures/BP_text.svg b/figures/BP_text.svg index 6a5336e..c92f7ed 100644 --- a/figures/BP_text.svg +++ b/figures/BP_text.svg @@ -1,12 +1,12 @@ - + - 2025-11-27T16:19:24.150236 + 2025-11-28T09:37:16.401430 image/svg+xml @@ -20,5 +20,5 @@ +iVBORw0KGgoAAAANSUhEUgAAAFMAAAAvCAYAAACfUva6AAAD3ElEQVR4nO2b73HbMAzFf+hlAF07QZ0NnG6QZAO3IzgbONcJes4GTSdIkw3sbtB4g3iEhhugH0g3MgXbsv6Rvuu70wdDMgg+USSERwkwBb7TLxywBv4AC+BJVddNnYnIJmbX4O8FcN6m/V04w3dwVWpodOA/a+p3YhR8FsA42K6AuYisgVtVfaod7RuOjdmF/7gGbdWHqlYO/F3X6Hi2rq1z4ImcAy+G3xdg3NT3gZgVmLb1XTuGPcHFQc06aRBmfXW6ywHQ5Hi3Z9C6FgN+J1T1DjjHTxdlfBeRWUv3Lvrd+by4D/vI7A3qJ/8Lqp2fi8hk+Ii6QRIyAVTVAZfGqUcRKYaNphskIxNAVVfAvXFqPnQsXSApmQG3hm16iqMzOZnhcV8ap74MHEprJCczYGHYrgePoiVyIXNl2A691WSHXMj8Y9j+k9kQ7w3boAl3F8iFTGsU/iezIS4Mm7UoZY1cyLTSoJ+DR9ESyckUkSt8TbKM+5B/nhSSk0n11dGp6k2SSFoiKZlBfhhHZqv4cRJIRqaIjKlqT9eh+HGSSEJmmCefS6Y1cKGq1jv6yeBsyMZCJWiOV0Q3uFNVq3LUBSYiokdc73gT3n7j07Nl3cXwGDI/NCiLvccn5CN84WJTRV8BD/S/ai+BxxrXFcAH3pTOT/i5fAogIktgfvDJ2SNOvWILX02PBZ7Mojd1sBrzvIWvzZy+JdABoybqZBxYbXWydIcnYWS8xqTmTmbJ54iqRG1y0QuZO/zNIp+vXZPaB5kl38+HfA+2mquXeD+yvRPjUUTqzGk54JJtNXUWS9ODpkaq6lT1gu1i8EREXnLXfNQvlHHWMQ/5MpAuab9ku8Q2An4liqU2VPWeqtb/78lKtQnBAfH791hE+t6N1wXi9GgUXkKSbkJYUtV+piKSu1xh1VlvIH3V6MGw5V4xshSAtCMzwNqbmfteI0v8KyD99hjrLuf+mDvLKCJF6pFpIvM0qbCMquqyJFPzlix2ytKpK+1xlR3yl3itmJ8g/QJ0ZdiafDAwJKw9UA+QnkwrDco2cQ9zeTwAlhqklpQa0ITqyn23Y4XPBdYm3H8DIpUGVAA/IvNa+5MvWiPM79PI/Ll88wcnMxD5zHaKsflgIEsEIuNCzI1GH4TtI7PoIaiNKll+vFd4idd10ERx4PfRCDXL8s13+BFZ3Yu/o6rc9RdqE3yBIPbZZSXcivmFIzWnQNpV8BdX7hf7/Eno6NcS8119O1ngE9zCOHeP/26yjp8KwuLVdcyb7zwtPAHf9MAGiTN8h61EdF+jdeHwHVnjH+eFdrPRoK+YHS10878pFo23l4uRSwAAAABJRU5ErkJggg==" id="imageb50a6faef4" transform="scale(1 -1) translate(0 -33.84)" x="76.32" y="-86.4" width="59.76" height="33.84"/> diff --git a/figures/HP_text.svg b/figures/HP_text.svg index 0442f98..c36809e 100644 --- a/figures/HP_text.svg +++ b/figures/HP_text.svg @@ -1,12 +1,12 @@ - + - 2025-11-27T16:19:25.433661 + 2025-11-28T09:37:18.357034 image/svg+xml @@ -20,5 +20,5 @@ +iVBORw0KGgoAAAANSUhEUgAAAFYAAAAvCAYAAAB5ez3+AAACv0lEQVR4nO2b0XEaMRCGv824gIvTAXSA04FJB6SEQAdkUkGGEuwOMqEDSAexO7BLMOpg83DCnIUO7qQT8cN+MxrGO6d/NT+HTtaeBFgCK8DRj8p/flTVk31FZAb8Tsixz3Ojqo8t2nPgLkN7rKrPCX1PckU9oP2gK2B0po8DXoA+g+mbA6/vOlz30lPb+T5dtNNR1aNGfXdppM1i16c06l9JLMd8AO27Utpdm/iBvEFEKmAXhLeq+mXIL1VEwuTPqjoupP2oqjdDaHfhQyzYMmcOPg9FNIfM4QpqnyVqrJGPGVsIM7YQZmwhzNhCmLGFMGMLYcYWwowthBlbCDO2EGZsIczYQpixhTBjC2HGFsKMLcTV/x7ABZlFyjWncByKjn+BDXV5ynXpHK15QbRm5Bi+vDEJ/h6sriYiOw4leoAtdZH0HBXwiUPF93NEZ6Wq25MqJyqdsSpn6bYZsAq8C7RXGVoTjiu/D8CorU+fOfZeVWXIxoULfKmo6qOqLoAxhzFPgCcRWcb62MOrB6q6L88338pZicgqvNaMTeOWt+X1ZXjnmrEJ+JXB9yC8EpHXh7EZm4iq3nP8UsjrqsOMzSNcco1EZApmbC6bSGwBZmwuseWi3bED8BKJVWDG5uJiQRGpzNg8qlhQVZ0Zm8d1JPYMNhXkEu7OAazBjM0ltsX5C8zYZPw5jWkQ3qo/NmXGpnO0o4X/5wDM2CT8Zss8CH/VxkG892Zs7Cn7rvCm/gnCC1VdNwNRY/38EdLlNGFfQs1Y3lRCrWxtv+f60NBy1Hfq/dHFLTWeS5xMbDs9uCyk/QRUPXUq6gfUHcc1tM0pPaGeKxaNb6HvOddbPX9IeUo92afm+Kbth5RnwI8e2l3O6I5ov8PXwM+28ey58gKTRrJzBb7rRmtLHhLmcMQ3MFJyXBNfqLfRdUpzZLxX8A/XADcj87rctwAAAABJRU5ErkJggg==" id="image7c0bd615a5" transform="scale(1 -1) translate(0 -33.84)" x="74.88" y="-86.4" width="61.92" height="33.84"/> diff --git a/figures/LP_text.svg b/figures/LP_text.svg index 92cdd91..d60f784 100644 --- a/figures/LP_text.svg +++ b/figures/LP_text.svg @@ -1,12 +1,12 @@ - + - 2025-11-27T16:19:25.024292 + 2025-11-28T09:37:17.610001 image/svg+xml @@ -20,5 +20,5 @@ +iVBORw0KGgoAAAANSUhEUgAAAE4AAAAvCAYAAABNAvziAAAC3ElEQVR4nO2b7W3bMBCGnysyAJFukGxgdIM2GyQj1N4gRSco3A2cDYp4A7sb1NkgHiHhBtcfohOFPuqDdiw74AMQtijpdHp1oiieCHAL6IBlpaqkCjAO2z1nFAUumuznljPAAw9UOOCCZtZhnxQOOA+/XWg73hP9/PNhH9/x+HkkrvI925HxDLg+V4XqJMfAyrD3UvpebWCWsDV+j+gyfUg45gyn7nc6UCXiInHCvS5IsNfrlt93+ZSIQm9UP/WJZMPmWlWvgB/G6rbbz8JHy+sMG9mYwr0nqvobmETV54f2Y1cOLhyAqt4B81pVTsQNyiDCBb7X/ruhnMhlMOFCO3oXFi+H8iOXISMOYBp+SxvXB1XddKZLG5fBktLGZbGgRFwWB+247oujEU5ETirqBhcuPCDgxNq5wYWrUSIugxtex9xOgrOhHQBQ1Xn7VsfFsUTcyVGEy6QIl8lRtHF74lpEtMf2ntekzj+qN5hlYvR7i48k3JIqydSGAz7zmjH7AoyokkqIyBKYquqy0UqPZMjskMmQDsma58i/6Q62RmxnzlY05GRLGweo6oOqTqgGVDdvMiPgUURurX2KcDVCJu6St53xqYhM422LcDZfeZt+vI0jrwhnEJ6scf53KiKjzUIRLkFIYfqo+uWpXYRrJu6SXIjINyjCtbEw6iZQhGvDGtYvEdcB60MjB0W4NrxVKSKuCNeMsypV1RfhmrE+zVhDuVXbGBl1cyjCtXFl1P2BIlwSEXGErkeNpao+QBGuia0REWqf4BbhDMLL/Diqvql9dVCEiwmi/Y2qJ3Hu1xQu3N8xx/aJgmtZ7k0Yc1vVbHmqSLvb2jgxBm/NrDnozJWWHIE1s+aR/jN/HNUDYMZ2DmPRZE+o7uVJTeUukeV5O19qZl6VPSAi18BPuvvXNtdsY8Ml1s2BX5unZ4qzYGBUO5jHfrmNe9H1E0g5sQ/OsTuiKbo2KZ4d8qr/AeLXGCwy43I4AAAAAElFTkSuQmCC" id="image4bcefc2711" transform="scale(1 -1) translate(0 -33.84)" x="77.76" y="-86.4" width="56.16" height="33.84"/> diff --git a/figures/adapt_text.svg b/figures/adapt_text.svg new file mode 100644 index 0000000..d512db2 --- /dev/null +++ b/figures/adapt_text.svg @@ -0,0 +1,177 @@ + + + + + + + + 2025-11-28T10:15:50.602685 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/ascending_text.svg b/figures/ascending_text.svg index ef4a79d..e8c3b7f 100644 --- a/figures/ascending_text.svg +++ b/figures/ascending_text.svg @@ -1,12 +1,12 @@ - + - 2025-11-27T16:19:26.727815 + 2025-11-28T10:11:18.783353 image/svg+xml @@ -19,6 +19,332 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/bi1_text.svg b/figures/bi1_text.svg new file mode 100644 index 0000000..55dfe88 --- /dev/null +++ b/figures/bi1_text.svg @@ -0,0 +1,123 @@ + + + + + + + + 2025-11-28T10:15:53.457222 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/bi2_text.svg b/figures/bi2_text.svg new file mode 100644 index 0000000..e30bb1e --- /dev/null +++ b/figures/bi2_text.svg @@ -0,0 +1,127 @@ + + + + + + + + 2025-11-28T10:15:54.087592 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/bi3_text.svg b/figures/bi3_text.svg new file mode 100644 index 0000000..03c844e --- /dev/null +++ b/figures/bi3_text.svg @@ -0,0 +1,133 @@ + + + + + + + + 2025-11-28T10:15:54.703726 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/brain_text.svg b/figures/brain_text.svg index c7cb738..5d28d4b 100644 --- a/figures/brain_text.svg +++ b/figures/brain_text.svg @@ -1,12 +1,12 @@ - + - 2025-11-27T16:19:27.490158 + 2025-11-28T10:11:21.475727 image/svg+xml @@ -19,6 +19,237 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/conv1_text.svg b/figures/conv1_text.svg new file mode 100644 index 0000000..aa85b13 --- /dev/null +++ b/figures/conv1_text.svg @@ -0,0 +1,71 @@ + + + + + + + + 2025-11-28T10:15:51.310879 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/conv2_text.svg b/figures/conv2_text.svg new file mode 100644 index 0000000..f2b5a4a --- /dev/null +++ b/figures/conv2_text.svg @@ -0,0 +1,75 @@ + + + + + + + + 2025-11-28T10:15:52.126335 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/conv3_text.svg b/figures/conv3_text.svg new file mode 100644 index 0000000..5fe2775 --- /dev/null +++ b/figures/conv3_text.svg @@ -0,0 +1,81 @@ + + + + + + + + 2025-11-28T10:15:52.814110 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/db_text.svg b/figures/db_text.svg new file mode 100644 index 0000000..95e863c --- /dev/null +++ b/figures/db_text.svg @@ -0,0 +1,124 @@ + + + + + + + + 2025-11-28T10:15:50.215534 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/env_text.svg b/figures/env_text.svg new file mode 100644 index 0000000..3060d5d --- /dev/null +++ b/figures/env_text.svg @@ -0,0 +1,140 @@ + + + + + + + + 2025-11-28T10:15:49.570246 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/envdb_text.svg b/figures/envdb_text.svg new file mode 100644 index 0000000..75f1d8b --- /dev/null +++ b/figures/envdb_text.svg @@ -0,0 +1,198 @@ + + + + + + + + 2025-11-28T11:59:15.345917 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/feat1_text.svg b/figures/feat1_text.svg new file mode 100644 index 0000000..f246b25 --- /dev/null +++ b/figures/feat1_text.svg @@ -0,0 +1,124 @@ + + + + + + + + 2025-11-28T10:15:55.300377 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/feat2_text.svg b/figures/feat2_text.svg new file mode 100644 index 0000000..54d2dfb --- /dev/null +++ b/figures/feat2_text.svg @@ -0,0 +1,128 @@ + + + + + + + + 2025-11-28T10:15:56.004595 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/feat3_text.svg b/figures/feat3_text.svg new file mode 100644 index 0000000..3ab1748 --- /dev/null +++ b/figures/feat3_text.svg @@ -0,0 +1,134 @@ + + + + + + + + 2025-11-28T10:15:56.839864 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/fig_auditory_pathway.svg b/figures/fig_auditory_pathway.svg new file mode 100644 index 0000000..8e25b02 --- /dev/null +++ b/figures/fig_auditory_pathway.svg @@ -0,0 +1,1674 @@ + + + + diff --git a/figures/filt_text.svg b/figures/filt_text.svg new file mode 100644 index 0000000..3040fdb --- /dev/null +++ b/figures/filt_text.svg @@ -0,0 +1,140 @@ + + + + + + + + 2025-11-28T10:15:48.030923 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/grasshopper_vnc_sketch.svg b/figures/grasshopper_vnc_sketch.svg new file mode 100644 index 0000000..fc96150 --- /dev/null +++ b/figures/grasshopper_vnc_sketch.svg @@ -0,0 +1,1107 @@ + + + + diff --git a/figures/grasshopper_vnc_sketch_backup.svg b/figures/grasshopper_vnc_sketch_backup.svg new file mode 100644 index 0000000..912e3a9 --- /dev/null +++ b/figures/grasshopper_vnc_sketch_backup.svg @@ -0,0 +1,1109 @@ + + + + diff --git a/figures/integration_text.svg b/figures/integration_text.svg new file mode 100644 index 0000000..8e37443 --- /dev/null +++ b/figures/integration_text.svg @@ -0,0 +1,391 @@ + + + + + + + + 2025-11-28T10:11:20.146683 + image/svg+xml + + + Matplotlib v3.10.5, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/interneurons_text.svg b/figures/interneurons_text.svg index b8f89cc..762d979 100644 --- a/figures/interneurons_text.svg +++ b/figures/interneurons_text.svg @@ -1,12 +1,12 @@ - + - 2025-11-27T16:19:26.496410 + 2025-11-28T10:11:18.440526 image/svg+xml @@ -19,6 +19,295 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/neuronal_circuit_sketch.svg b/figures/neuronal_circuit_sketch.svg index f94e3a5..0cb6976 100644 --- a/figures/neuronal_circuit_sketch.svg +++ b/figures/neuronal_circuit_sketch.svg @@ -25,16 +25,16 @@ inkscape:deskcolor="#505050" inkscape:document-units="mm" showgrid="true" - inkscape:zoom="3.1999438" + inkscape:zoom="1.5999719" inkscape:rotation="90" - inkscape:cx="516.88408" - inkscape:cy="897.35951" + inkscape:cx="190.00334" + inkscape:cy="689.0746" inkscape:window-width="3840" inkscape:window-height="2040" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" - inkscape:current-layer="layer4"> + inkscape:label="4"> diff --git a/figures/receptors_text.svg b/figures/receptors_text.svg index 080c087..01bd109 100644 --- a/figures/receptors_text.svg +++ b/figures/receptors_text.svg @@ -1,12 +1,12 @@ - + - 2025-11-27T16:19:26.217264 + 2025-11-28T10:11:18.001971 image/svg+xml @@ -19,6 +19,303 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/threshold_text.svg b/figures/threshold_text.svg index ba69cc2..fccf65a 100644 --- a/figures/threshold_text.svg +++ b/figures/threshold_text.svg @@ -1,12 +1,12 @@ - + - 2025-11-27T16:19:26.979087 + 2025-11-28T10:11:19.227586 image/svg+xml @@ -19,6 +19,377 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figures/tympanum_text.svg b/figures/tympanum_text.svg index 6e19773..97baacb 100644 --- a/figures/tympanum_text.svg +++ b/figures/tympanum_text.svg @@ -1,12 +1,12 @@ - + - 2025-11-27T16:19:25.816378 + 2025-11-28T10:11:16.919801 image/svg+xml @@ -19,6 +19,331 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/save_latex_texts.py b/python/save_latex_texts.py index b6c7052..62fdc0e 100644 --- a/python/save_latex_texts.py +++ b/python/save_latex_texts.py @@ -4,35 +4,27 @@ plt.rcParams['text.usetex'] = True plt.rcParams['font.family'] = 'computer modern roman' plt.rcParams['mathtext.fontset'] = 'cm' plt.rcParams['mathtext.default'] = 'regular' - -# Targets: -texts = { - 'BP': ('BP', 25), - 'LP': ('LP', 25), - 'HP': ('HP', 25), - 'tympanum': ('Tympanal\nMembrane', 13), - 'receptors': ('Receptor\nNeurons', 13), - 'interneurons': ('Local\nInterneurons', 13), - 'ascending': ('Ascending\nNeurons', 13), - 'threshold': ('Threshold\nNonlinearity', 13), - 'brain': ('Central\nBrain', 13), -} +plt.rcParams['svg.fonttype'] = 'path' +plt.rc('text.latex', preamble=r'\usepackage{amsmath}') # Settings: +fs_chart = 70 +fs_legend = 40 show_figs = True +grid_props = dict(left=0, right=1, top=1, bottom=0) fig_props = { - 'figsize': (1, 1), + 'figsize': (3, 3), 'facecolor': 'none', 'edgecolor': 'none', 'frameon': False, - 'rasterized': True, + # 'rasterized': True, } ax_props = { 'facecolor': 'none', 'frame_on': False, - 'rasterized': True, + # 'rasterized': True, } text_props = { @@ -41,21 +33,44 @@ text_props = { 'y': 0.5, 'ha': 'center', 'va': 'center', - 'rasterized': True, + # 'rasterized': True, } -# Prepare variables: -grid_props = dict(left=0, right=1, top=1, bottom=0) +# Targets: +texts = { + 'filt': (r'$x_{\text{filt}}$', fs_chart), + 'env': (r'$x_{\text{env}}$', fs_chart), + 'db': (r'$x_{\text{dB}}$', fs_chart), + 'envdb': (r'$\begin{array}{c}x_{\text{env}}\\x_{\text{dB}}\end{array}$', fs_chart), + 'adapt': (r'$x_{\text{adapt}}$', fs_chart), + 'conv1': (r'$c_1$', fs_chart), + 'conv2': (r'$c_2$', fs_chart), + 'conv3': (r'$c_3$', fs_chart), + 'bi1': (r'$b_{1, \Theta}$', fs_chart), + 'bi2': (r'$b_{2, \Theta}$', fs_chart), + 'bi3': (r'$b_{3, \Theta}$', fs_chart), + 'feat1': (r'$f_{1, \Theta}$', fs_chart), + 'feat2': (r'$f_{2, \Theta}$', fs_chart), + 'feat3': (r'$f_{3, \Theta}$', fs_chart), + 'BP': ('BP', fs_chart), + 'LP': ('LP', fs_chart), + 'HP': ('HP', fs_chart), + 'tympanum': ('Tympanal\nMembrane', fs_legend), + 'receptors': ('Receptor\nNeurons', fs_legend), + 'interneurons': ('Local\nInterneurons', fs_legend), + 'ascending': ('Ascending\nNeurons', fs_legend), + 'threshold': ('Threshold\nNonlinearity', fs_legend), + 'integration': ('Temporal\nAveraging', fs_legend), + 'brain': ('Central\nBrain', fs_legend), +} # Save each target string: for name, (text, fs) in texts.items(): - # print(f'Saving text figure for: {name}') - # print(name, text, fs) fig, ax = plt.subplots(1, 1, gridspec_kw=grid_props, **fig_props) ax.set(**ax_props) ax.axis('off') ax.text(s=text, fontsize=fs, **text_props) - fig.savefig(f'../figures/{name}_text.svg', + fig.savefig(f'../figures/{name}_text.svg', dpi=300, bbox_inches='tight', pad_inches=0) if show_figs: plt.show() @@ -64,131 +79,131 @@ for name, (text, fs) in texts.items(): -def text_box(ax, text, xy, width, height, transform=None, - ha='center', va='center', **kwargs): - """ Maximizes fontsize of text to fit into a given bounding box. - Calculated fontsize depends on the aspect ratio of the bounding box, - the aspect ratio and alignment of the text, and the resolution and size - of the underlying figure. Text is not updated when resizing the figure. +# def text_box(ax, text, xy, width, height, transform=None, +# ha='center', va='center', **kwargs): +# """ Maximizes fontsize of text to fit into a given bounding box. +# Calculated fontsize depends on the aspect ratio of the bounding box, +# the aspect ratio and alignment of the text, and the resolution and size +# of the underlying figure. Text is not updated when resizing the figure. - Parameters - ---------- - ax : matplotlib axes object - Target subplot to annotate the text. - text : str - Text to fit into the specified bounding box under the given alignments. - xy : tuple of floats or ints (2,) - Text position in the coordinate system specified by transform. - width : float or int - Rectangle width in the coordinate system specified by transform. - height : float or int - Rectangle height in the coordinate system specified by transform. - transform : matplotlib transform, optional - Underlying coordinate system of the bounding box. Determines the - interpretation of xy, width, and height. Falls back to data coordinates - if unspecified. The default is None. - ha : str, optional - Horizontal alignment of bounding box and text relative to the given xy. - The default is 'center'. - va : str, optional - Vertical alignment of bounding box and text relative to the given xy. - The default is 'center'. - **kwargs : dict, optional - Additional keyword arguments passed to ax.annotate() for specifying - different font properties of the returned text object. +# Parameters +# ---------- +# ax : matplotlib axes object +# Target subplot to annotate the text. +# text : str +# Text to fit into the specified bounding box under the given alignments. +# xy : tuple of floats or ints (2,) +# Text position in the coordinate system specified by transform. +# width : float or int +# Rectangle width in the coordinate system specified by transform. +# height : float or int +# Rectangle height in the coordinate system specified by transform. +# transform : matplotlib transform, optional +# Underlying coordinate system of the bounding box. Determines the +# interpretation of xy, width, and height. Falls back to data coordinates +# if unspecified. The default is None. +# ha : str, optional +# Horizontal alignment of bounding box and text relative to the given xy. +# The default is 'center'. +# va : str, optional +# Vertical alignment of bounding box and text relative to the given xy. +# The default is 'center'. +# **kwargs : dict, optional +# Additional keyword arguments passed to ax.annotate() for specifying +# different font properties of the returned text object. - Returns - ------- - t : matplotlib text object - Annotated text object with adjusted fontsize to fit the bounding box. - """ - # Input interpretation: - if transform is None: - transform = ax.transData - fig = ax.get_figure() - x, y = xy - # Alignment-specific anchor points: - x_align1, x_align2 = { - 'center': (x - width / 2, x + width / 2), - 'left': (x, x + width), - 'right': (x - width, x), - }[ha] - y_align1, y_align2 = { - 'center': (y - height / 2, y + height / 2), - 'bottom': (y, y + height), - 'top': (y - height, y), - }[va] - # Anchor points in pixel: - left_corner = transform.transform((x_align1, y_align1)) - right_corner = transform.transform((x_align2, y_align2)) - # Bounding rectangle size in pixel: - pixel_width = right_corner[0] - left_corner[0] - pixel_height = right_corner[1] - left_corner[1] - # Adjust fontsize to box height (inch): - dpi = fig.dpi - rect_height = pixel_height / dpi - fs_initial = rect_height * 72 - # Plot first draft of the text: - t = ax.annotate(text, xy, ha=ha, va=va, xycoords=transform, **kwargs) - t.set_fontsize(fs_initial) - # Adjust fontsize to box width (inch): - bbox = t.get_window_extent(fig.canvas.get_renderer()) - fs_adjusted = fs_initial * pixel_width / bbox.width - t.set_fontsize(fs_adjusted) - return t +# Returns +# ------- +# t : matplotlib text object +# Annotated text object with adjusted fontsize to fit the bounding box. +# """ +# # Input interpretation: +# if transform is None: +# transform = ax.transData +# fig = ax.get_figure() +# x, y = xy +# # Alignment-specific anchor points: +# x_align1, x_align2 = { +# 'center': (x - width / 2, x + width / 2), +# 'left': (x, x + width), +# 'right': (x - width, x), +# }[ha] +# y_align1, y_align2 = { +# 'center': (y - height / 2, y + height / 2), +# 'bottom': (y, y + height), +# 'top': (y - height, y), +# }[va] +# # Anchor points in pixel: +# left_corner = transform.transform((x_align1, y_align1)) +# right_corner = transform.transform((x_align2, y_align2)) +# # Bounding rectangle size in pixel: +# pixel_width = right_corner[0] - left_corner[0] +# pixel_height = right_corner[1] - left_corner[1] +# # Adjust fontsize to box height (inch): +# dpi = fig.dpi +# rect_height = pixel_height / dpi +# fs_initial = rect_height * 72 +# # Plot first draft of the text: +# t = ax.annotate(text, xy, ha=ha, va=va, xycoords=transform, **kwargs) +# t.set_fontsize(fs_initial) +# # Adjust fontsize to box width (inch): +# bbox = t.get_window_extent(fig.canvas.get_renderer()) +# fs_adjusted = fs_initial * pixel_width / bbox.width +# t.set_fontsize(fs_adjusted) +# return t -def text_graph(text, save_str=None, size=None, ax=None, show=False, - close=False, **kwargs): - """ Turns entire subplot into a text box that displays the given text. - Fontsize is maximized to fit the available bounding box. Text is always - centered in the subplot. Meant for creating scalable text elements that - comply with the style of other plot elements, especially for posters. +# def text_graph(text, save_str=None, size=None, ax=None, show=False, +# close=False, **kwargs): +# """ Turns entire subplot into a text box that displays the given text. +# Fontsize is maximized to fit the available bounding box. Text is always +# centered in the subplot. Meant for creating scalable text elements that +# comply with the style of other plot elements, especially for posters. - Parameters - ---------- - text : str - Text to be displayed. Can be multiline. Text fontsize is maximized by - text_box() to fit a bounding box that covers the entire axes area. - save_str : str, optional - If specified, saves the underlying figure under the given path. For - best results, use a vector format such as .svg). The default is None. - size : tuple of floats or ints (2,), optional - If specified, creates a new figure with given size in inches and a - single subplot. Indirectly controls the aspect ratio of the text box. - Must be specified if ax is None. The default is None. - ax : matplotlib axes object, optional - If specified, the target subplot to turn into a text box. Can be used - to set more properties such as the background color of the text box. - Must be specified if size is None. The default is None. - show : bool, optional - If True, displays the figure before returning. Else, returns without - showing the figure. The default is False. - **kwargs : dict, optional - Keyword arguments passed to text_box() and further to ax.annotate() for - specifying additional font properties of the displayed text. +# Parameters +# ---------- +# text : str +# Text to be displayed. Can be multiline. Text fontsize is maximized by +# text_box() to fit a bounding box that covers the entire axes area. +# save_str : str, optional +# If specified, saves the underlying figure under the given path. For +# best results, use a vector format such as .svg). The default is None. +# size : tuple of floats or ints (2,), optional +# If specified, creates a new figure with given size in inches and a +# single subplot. Indirectly controls the aspect ratio of the text box. +# Must be specified if ax is None. The default is None. +# ax : matplotlib axes object, optional +# If specified, the target subplot to turn into a text box. Can be used +# to set more properties such as the background color of the text box. +# Must be specified if size is None. The default is None. +# show : bool, optional +# If True, displays the figure before returning. Else, returns without +# showing the figure. The default is False. +# **kwargs : dict, optional +# Keyword arguments passed to text_box() and further to ax.annotate() for +# specifying additional font properties of the displayed text. - Raises - ------ - ValueError - Breaks if neither size nor ax is specified to define a target subplot. - """ - # Input interpretation: - if size is not None: - fig, ax = plt.subplots(figsize=size) - elif ax is not None: - fig = ax.get_figure() - else: - raise ValueError('Either size or ax must be specified.') - # Turn drawable area of axes into a single text box: - text_box(ax, text, (0.5, 0.5), 1, 1, ax.transAxes, **kwargs) - # Hide other axes elements: - ax.xaxis.set_visible(False) - ax.yaxis.set_visible(False) - ax.spines[:].set_visible(False) - # Return options: - if save_str is not None: - fig.savefig(save_str, bbox_inches='tight') - if show: - plt.show() - return None \ No newline at end of file +# Raises +# ------ +# ValueError +# Breaks if neither size nor ax is specified to define a target subplot. +# """ +# # Input interpretation: +# if size is not None: +# fig, ax = plt.subplots(figsize=size) +# elif ax is not None: +# fig = ax.get_figure() +# else: +# raise ValueError('Either size or ax must be specified.') +# # Turn drawable area of axes into a single text box: +# text_box(ax, text, (0.5, 0.5), 1, 1, ax.transAxes, **kwargs) +# # Hide other axes elements: +# ax.xaxis.set_visible(False) +# ax.yaxis.set_visible(False) +# ax.spines[:].set_visible(False) +# # Return options: +# if save_str is not None: +# fig.savefig(save_str, bbox_inches='tight') +# if show: +# plt.show() +# return None \ No newline at end of file