Skip to content

latex_octaved_sargam_letter should use Unicode for lower octaves due to matplotlib incompatibility #24

@jon-myers

Description

@jon-myers

Issue Description

The latex_octaved_sargam_letter property produces LaTeX syntax that doesn't render properly in matplotlib for lower octaves, making the API output unusable in the most common Python plotting scenario.

Problem

Currently, latex_octaved_sargam_letter outputs:

  • Upper octaves: $\dot{\mathrm{D}}$ ✅ Works in matplotlib
  • Lower octaves: $\underset{\cdot}{\mathrm{D}}$Doesn't render in matplotlib

The \underset command is not supported by matplotlib's LaTeX engine, so lower octave diacritics simply don't appear, leaving users with broken output.

Impact

  • Any visualization using matplotlib will have missing lower octave diacritics
  • Users must implement workarounds, defeating the purpose of a "latex" property
  • API is inconsistent - works for upper octaves, fails for lower octaves

Proposed Solution

Update latex_octaved_sargam_letter to use Unicode characters directly for lower octaves:

  • Upper octaves: $\dot{\mathrm{D}}$ (keep LaTeX - works perfectly)
  • Lower octaves: (use Unicode directly - works perfectly)
  • Normal octave: D (no change needed)

This would make the API robust and usable across all plotting libraries.

Example

from idtap.classes.pitch import Pitch

# Current (broken in matplotlib):
p_lower = Pitch({'swara': 'dha', 'oct': -1, 'raised': True})
print(p_lower.latex_octaved_sargam_letter)  # '$\\underset{\\cdot}{\\mathrm{D}}$' - doesn't render

# Proposed (works everywhere):
print(p_lower.latex_octaved_sargam_letter)  # 'Ḍ' - renders perfectly

Context

Discovered while implementing cyclic visualizations. Had to implement a workaround that checks octave levels and uses Unicode for lower octaves manually, which defeats the purpose of having a dedicated LaTeX property in the API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions