Skip to content

TikZ backend: coordinate scaling policy (display units → cm) #52

@yueswater

Description

@yueswater

Sub-issue of #50.

Problem

Matplotlib delivers display coordinates (points / pixels). TikZ works
natively in cm. Without a conversion factor, a typical 6×4 in figure
explodes into a 15+ cm picture that breaks page layout in textbooks and
slide templates.

Proposed fix

Expose scale as a constructor argument on TikzRenderer (default 0.5,
cm per display unit after Matplotlib's internal DPI) and surface an
override at the Canvas.save(..., tikz_scale=...) layer.

Optionally derive a default from fig.get_size_inches() so a 6×4 in
figure maps to a reasonable ~7.5×5 cm TikZ picture without manual tuning.

Acceptance criteria

  • TikzRenderer(..., scale=s) multiplies every emitted coordinate by s.
  • Canvas.save('plot.tex', tikz_scale=0.4) propagates cleanly.
  • A Cobb–Douglas example renders within a target bounding box
    (e.g. ≤ 10 cm wide) by default.
  • Scale behavior documented alongside other Canvas.save options.

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