You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

除Unicode块元素外,适合控制台绘制热力图的字符有哪些?

Great question! When building console-based heatmaps, the key is finding Unicode characters that offer smooth grayscale transitions while keeping consistent aspect ratios (your trick of doubling characters horizontally to fix the tall-wide font issue is spot-on). Here are some top alternatives to expand your symbol toolkit:

1. Extended Block Elements

Your current set ( ░▒▓█) is a solid start, but you can add quarter-block and half-block characters to create more granular gray levels:

  • ▘ (U+2598), ▝ (U+259D), ▗ (U+2597), ▖ (U+2596): These quarter-filled blocks fit perfectly between empty space and the lightest shade (░), adding 4 extra transition steps.
  • ▌ (U+258C), ▐ (U+2590): Left/right half-blocks work as mid-gray alternatives, ideal for filling gaps between ░ and ▒.
  • ▀ (U+2580), ▄ (U+2584): Top/bottom half-blocks can also be mixed in to create more nuanced shading.

2. Braille Patterns (Super Granular!)

Braille symbols (U+2800 to U+28FF) are a game-changer for console heatmaps. Each character uses a 2x4 dot grid, giving you up to 64 distinct grayscale levels—perfect for ultra-detailed visualizations. Examples include:

  • ⠀ (U+2800, completely empty)
  • ⠁ (U+2801, single dot)
  • ⠂ (U+2802, two dots)
  • ... all the way to ⣿ (U+28FF, full dot grid)

Since braille characters are naturally 2 rows tall, you may not need to double them horizontally (adjust based on your console font's aspect ratio).

3. Oblique Shade Characters

For a slightly different visual style, these diagonal-fill symbols add unique mid-gray options:

  • ◜ (U+25DC), ◝ (U+25DD), ◞ (U+25DE), ◟ (U+25DF): These corner-filled blocks provide subtle shading variations that complement standard block elements.

4. Circle Gradients

If you prefer rounded shapes, hollow-to-solid circles offer a clear grayscale progression:

  • ◯ (U+25EF, hollow circle) → ◑ (U+25D1, half-filled) → ◒ (U+25D2, mostly filled) → ● (U+25CF, solid circle)

Just note that some console fonts may render circles as non-square, so you might still need to double them horizontally to maintain aspect ratio.

Modified Python Example with Extended Symbols

Here’s how you can update your code to support multiple symbol sets:

import numpy as np

def ascii_heatmap(matrix: np.ndarray, disp=True, symbol_set='default'):
    assert matrix.ndim <= 2
    matrix = np.atleast_2d(matrix)
    vmax = matrix.max()
    vmin = matrix.min()
    
    # Select symbol sets based on preference
    if symbol_set == 'extended_blocks':
        # 9 levels of gray with quarter-blocks
        symbolrange = ' ▘▝▗▖░▒▓█'
    elif symbol_set == 'braille':
        # 16 simplified braille levels (expandable to 64)
        symbolrange = '⠀⠁⠂⠄⠈⠐⠠⠤⠨⠰⠸⠾⠿⣿'
    elif symbol_set == 'circles':
        # 4-level circle gradient
        symbolrange = ' ◯◑◒●'
    else:
        # Original 5-level set
        symbolrange = ' ░▒▓█'
    
    # Calculate and clamp symbol indices
    symbol_index_matrix = np.clip(
        (matrix - vmin) * (len(symbolrange)-1) / (vmax - vmin),
        0, len(symbolrange)-1
    ).astype(int)
    
    heatmap_rows = []
    # Adjust multiplier based on symbol set (braille needs less scaling)
    multiplier = 1 if symbol_set == 'braille' else 2
    for row in symbol_index_matrix:
        heatmap_rows.append("".join([symbolrange[x] * multiplier for x in row]))
    
    heatmap = "\n".join(heatmap_rows)
    if disp:
        print(heatmap)
    return heatmap

# Test extended block heatmap
ascii_heatmap(np.arange(9).reshape((3,3)), symbol_set='extended_blocks')
# Test high-detail braille heatmap
ascii_heatmap(np.random.rand(10,10), symbol_set='braille')

Quick Tips

  • Font Support: Not all console fonts render every Unicode character correctly. Stick to fonts like Consolas, DejaVu Sans Mono, or Noto Sans Mono for best results.
  • Smooth Transitions: When building custom symbol sets, arrange characters in order of increasing visual density to ensure the heatmap gradients feel natural.
  • Aspect Ratio: Most console fonts are 1:2 (width:height), so doubling characters horizontally will keep your heatmap from looking stretched vertically.

内容的提问来源于stack exchange,提问作者LudvigH

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:57:16