Fonts in Plots. Paul Murrell. July 5 2006



Similar documents
When older typesetting methods gave

How to Copyright Your Book

The gensymb package for L A TEX 2ε

A Tutorial on Creating Presentations Using Beamer

Fonts for Displaying Program Code in L A TEX

Guide for writing assignment reports

CGN Computer Methods

Producing accessible materials for print and online

Visual Communication Program Assessment Revised Graphic Design Portfolio Checklist/Assessment

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

1.6 The Order of Operations

1UNIVERSITY, The Logo STANDARD 2.1

Formatting Text in Microsoft Word

MANUSCRIPT TITLE (CENTERED, 14 POINT BOLD, SANS SERIF FONT, MAJUSCULE)

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Adrian Frutiger: A personal perspective

L A TEX in a Nutshell

Guide to design and layout

ITCS QUICK REFERENCE GUIDE: EXPRESSION WEB SITE

Graphic Design Basics. Shannon B. Neely. Pacific Northwest National Laboratory Graphics and Multimedia Design Group

(1) latex + dvipdfm (which is a DVI to PDF translator) or (2) pdflatex (a version of LaTeX that generates PDF output instead of DVI).

How to make more than one math OpenType font

Algebra. Exponents. Absolute Value. Simplify each of the following as much as possible. 2x y x + y y. xxx 3. x x x xx x. 1. Evaluate 5 and 123

Math Matters: Why Do I Need To Know This? 1 Probability and counting Lottery likelihoods

The plain English guide to forms

In order to describe motion you need to describe the following properties.

The Three Little Pigs. Reader s Theater Script. Characters. First Pig Second Pig Third Pig Wolf Farmer

Guidelines for Creating Accessible Printed Posters. Stephen F. Gilson, Ph.D. Robert M. Kitchin Jr., MSW

Colour Science Typography Frontend Dev

CALCULATIONS & STATISTICS

Microsoft Expression Web Quickstart Guide

Basics of HTML (some repetition) Cascading Style Sheets (some repetition) Web Design

DOING MORE WITH WORD: MICROSOFT OFFICE 2010

Vector Calculus: a quick review

The Mathematics 11 Competency Test Percent Increase or Decrease

Reading 13 : Finite State Automata and Regular Expressions

Grade 8 Mathematics Measurement: Lesson 6

Section 1.4 Place Value Systems of Numeration in Other Bases

Adjunct Assistant Professor Gayle Rembold Furbert. Typography II. County College of Morris Graphic Design Degree Program

HTML and CSS. Elliot Davies. April 10th,

BASICS OF WEB DESIGN CHAPTER 2 HTML BASICS KEY CONCEPTS COPYRIGHT 2013 TERRY ANN MORRIS, ED.D

Planning and preparing presentations Giving presentations Features of a good presentation Poster presentations

Preface of Excel Guide

Each function call carries out a single task associated with drawing the graph.

Useful Mathematical Symbols

Financial Mathematics

Setting up and using in PGdebt 9

Creating Formulas II. Multiplication/Division Percentages Order of Operations Relative and Absolute Reference

LESSON TITLE: Spiritual Gifts. THEME: God gives us all different gifts to serve Him and to serve others! SCRIPTURE: 1 Corinthians 12:1-31; 14:1-40

Handbook for Preparation of Graduate Dissertations, Projects, and Theses

Guidelines for Seminar Papers and Final Papers (BA / MA Theses) at the Chair of Public Finance

BLACKBOARD 9.1: Text Editor

How to Graph Trigonometric Functions

Grade 7/8 Math Circles November 3/4, M.C. Escher and Tessellations

Vectors VECTOR PRODUCT. Graham S McDonald. A Tutorial Module for learning about the vector product of two vectors. Table of contents Begin Tutorial

Welcome to Math Video Lessons. Stanley Ocken. Department of Mathematics The City College of New York Fall 2013

Modern PHP Graphics with Cairo. Michael Maclean FrOSCon 2011

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Creating A Grade Sheet With Microsoft Excel

CONTINGENCY TABLES ARE NOT ALL THE SAME David C. Howell University of Vermont

XMGrace Fancy characters and stuff

9.2 User s Guide SAS/STAT. Introduction. (Book Excerpt) SAS Documentation

Maple Quick Start. Introduction. Talking to Maple. Using [ENTER] 3 (2.1)

HOW TO SUCCEED WITH NEWSPAPER ADVERTISING

Preparing graphics for IOP journals

Running Wordstar 6 on Windows 7 Using vdos

Microsoft Excel 2010 Part 3: Advanced Excel

Advice to USENIX authors: preparing presentation slides

CA Application Tips Sheet

A send-a-friend application with ASP Smart Mailer

2. Basic operations

Serif or Modern Fonts

Divide your material into sections, for example: Abstract, Introduction, Methods, Results, Conclusions

How to Write a Design Report ver:

VANILLA OPTIONS MANUAL

Word Processing programs and their uses

Direct Translation is the process of translating English words and phrases into numbers, mathematical symbols, expressions, and equations.

Use APA Style Formatting with Microsoft Word 2010

Tutorial Microsoft Office Excel 2003

MathType. Mathematical Equation Editor USER MANUAL

Using sentence fragments

WBU PowerPoint Guidelines

Graphic Standards Manual

xn. x must be written as x^(2n) and NOT as x^2n. Writing x^2n means 4x y would be written as 4 x^2 y^3 or with the multiplication mark as 4*x^2*y^3.

Excel Guide for Finite Mathematics and Applied Calculus

Flash Card Exercises to Teach Basic Literacy Skills to Pre-Literate Students

Missing cat website HTML&CSS. The Mission:

50 TUGboat, Volume 31 (2010), No. 1. Plotting experimental data using pgfplots Joseph Wright

Version of Barcode Toolbox adds support for Adobe Illustrator CS

A Quick Algebra Review

Creating a Resume Webpage with

Knowledge Base for Electronic Editing Tools

Chapter 4: Computer Codes

7 PROVEN TIPS GET MORE BUSINESS ONLINE

Transcription:

Fonts in Plots Paul Murrell July 5 2006

Selecting Fonts in R Font size The size of text can be controlled via absolute point size and through the use of a character expansion multiplier. text(x, y, "whatever", cex=2) grid.text("whatever", gp=gpar(cex=2, fontsize=10)) Font face The style of text can be chosen from plain (or roman), bold, italic, bold-italic, or symbol. text(x, y, "whatever", font=2) grid.text("whatever", gp=gpar(fontface="bold"))

Selecting Fonts in R Font family The overall font can be chosen from sans-serif, serif, or monospaced. text(x, y, "whatever", family="serif") grid.text("whatever", gp=gpar(fontfamily="serif")) Custom font family A new font can be defined using a font database which maps a family name to font details. pdffonts(cmss=type1font("computer Modern", c("cmpsfont/afm/cmss10.afm", "cmpsfont/afm/cmssbx10.afm", "cmpsfont/afm/cmssi10.afm", "cmpsfont/afm/cmssbx10.afm")))

Why Worry? Legibility The choice of font is important for legibility: a sans serif font is more likely to be legible in small pieces of text, especially on screen. Legibility is Good with a Sans Serif Font Variable Y 15 5 5 15 15 5 5 15 Variable X

Why Worry? Consistency The choice of font can be important for consistency: it can look nicer and more professional if the font used in figures matches the font used in the main text of a book or report. This is Helvetica This is Computer Modern Sans Serif Variable Y 15 5 5 15 Variable Y 15 5 5 15 15 5 5 15 Variable X 15 5 5 15 Variable X

Why Worry? Special characters The choice of font can be forced upon you: sometimes you need a character that is only available in a particular font. log Likelihood 232 231 230 229 228 (θ^) χ 12 (0.95) 2 log Likelihood 232 231 230 229 228 l(θˆ) χ 12 (0.95) 2 0.45 0.50 0.55 0.60 0.65 0.70 0.45 0.50 0.55 0.60 0.65 0.70 Theta Theta

Why Worry? Localisation The choice of font can be cultural: some languages require a particular font because they use a completely different set of characters. Hello World

Why Worry? Aesthetics The choice of font can be a matter of taste: sometimes you need the right font to make text look nice. At first sight it must seem intolerably degrading for Zen however the reader may understand this word to be associated with anything so mundane as archery. Even if he were willing to make the big concession, and to find archery distinguished as an art, he would scarcely feel inclined to look behind this art for anything more than a decidedly sporting form of prowess. He therefore expects to be told something about the amazing feats of Japanese trick-artists who have the advantage of being able to rely on a timehonored and unbroken tradition in the use of bow and arrow. For in the Far East it is only a few generations since the old means of combat were replaced by modern methods, and familiarity in the handling of them by no means fell into disuse, but went on propagating itself, and has since been cultivated in ever widening circles. Might one not expect, therefore, a description of the special ways in which archery is pursued today as a national sport in Japan? At first sight it must seem intolerably degrading for Zen however the reader may understand this word to be associated with anything so mundane as archery. Even if he were willing to make the big concession, and to find archery distinguished as an art, he would scarcely feel inclined to look behind this art for anything more than a decidedly sporting form of prowess. He therefore expects to be told something about the amazing feats of Japanese trickartists who have the advantage of being able to rely on a time-honored and unbroken tradition in the use of bow and arrow. For in the Far East it is only a few generations since the old means of combat were replaced by modern methods, and familiarity in the handling of them by no means fell into disuse, but went on propagating itself, and has since been cultivated in ever widening circles. Might one not expect, therefore, a description of the special ways in which archery is pursued today as a national sport in Japan?

Mathematical Formulas in Plots The champion TEX is the gold standard for formatting mathematical formulas. The pretender R provides a mechanism for formatting mathematical formulas, which attempts to emulate TEX. How does it do? 1 σ 2π e (x µ) 2σ 2 2 1 e (x µ)2 2σ 2 σ 2π

Mathematical Formulas in Plots A token effort We can do a little bit better with a serif font and some italics. 1 σ 2π e (x µ) 2σ 2 2 1 σ 2π e (x µ)2 2σ 2 1 e (x µ)2 2σ 2 σ 2π

The Problem Confession A minor problem is that we are using a Times font not TEX s Computer Modern Math Italic font. This can easily be fixed by specifying the appropriate font. The main problem is that we are using the Adobe Symbol font not TEX s Computer Modern Math Symbol font. This is not so easy to fix because just using the appropriate font fails miserably. 1 σ 2π e (x µ) 2σ 2 2 1 2 e x 2 2 2

The Problem The gory details The underlying problem is that R assumes that the symbol font uses the Adobe Symbol Encoding, but the Computer Modern fonts use special TEX-specific encodings. Another problem is that the Computer Modern Math Symbol font does not contain (anywhere near) all of the symbols in the Adobe Symbol Encoding. suchthat similarequal ( parenleft arrowdblleft ) parenright arrowdblright asteriskmath arrowdblup + plus arrowdbldown, comma arrowdblboth minus arrownorthwest

The Solution What would any self-respecting Statistician do? Create a new font of course! Source: FontForge editing tutorial http://fontforge.sourceforge.net/editexample.html How do you create a new font? 1 Pay lots of money to someone with lots of talent. 2 Use a fancy program and spend many hours fiddling. 3 Cheat.

The Solution The structure of a Type 1 font A Type 1 font consists of a font metric file, fontname.afm, which is a text file, and a font outline file, fontname.pfb, which is a binary file. The t1disasm program (from t1utils) turns fontname.pfb into fontname.raw, which is a text file.... C 39 ; WX 666.667 ; N suchthat ; B 83-40 583 540 ; C 40 ; WX 388.889 ; N parenleft ; B 99-250 331 750 ; C 41 ; WX 388.889 ; N parenright ; B 57-250 289 750 ; C 42 ; WX 500 ; N asteriskmath ; B 65 34 434 465 ; C 43 ; WX 777.778 ; N plus ; B 56-83 721 583 ; C 44 ; WX 277.778 ; N comma ; B 86-193 203 106 ; C 45 ; WX 777.778 ; N minus ; B 83 230 694 270 ;...... /minus { 83 7000 9 div hsbw 230 40 hstem 0 611 vstem 578 230 rmoveto 14 19 0 20 hvcurveto 20-19 0-14 vhcurveto -545 hlineto -14-19 0-20 hvcurveto -29 4 vhcurveto closepath endchar } ND...

The Solution Pick n Mix A new font can be created from existing fonts by simply reordering and combining character metric and outline information (in text formats). The full Adobe Symbol Encoding requires characters from: Computer Modern Roman (e.g., space, left and right parentheses) Computer Modern Math Symbol (e.g., core math symbols, minus) Computer Modern Math Italic (e.g., less than, greater than, Greek symbols) Computer Modern Math Extension (e.g., arrows, math operators) AMS Math Symbol [A] (therefore, angle, lozenge) The t1asm program (from t1utils) turns fontname.raw into fontname.pfb.

The Solution Computer Modern Adobe-Symbol-Encoding Math Symbol The font can be obtained from http://www.stat.auckland.ac.nz/~paul/r/cm/cmr.html as cmsyase.afm and cmsyase.pfb. Limitations The proposed solution involves a Type 1 font, which covers PDF and PostScript output. A Windows port is possible in theory, but has not worked yet in practice. The new font is still missing some characters and some could do with a bit more polish.

Mathematical Formulas in Plots Almost perfect Using the Computer Modern Adobe-Symbol-Encoding Math Symbol font and the Computer Modern Math Italic font. 1 σ 2π e (x µ) 2σ 2 2 1 σ 2π e (x µ)2 2σ 2 1 e (x µ)2 2σ 2 σ 2π

The Solution Another example On the left, Helvetica; on the right, Computer Modern Sans Serif and Computer Modern Adobe-Symbol-Encoding Math Symbol. log Likelihood 232 231 230 229 228 (θ^) χ 12 (0.95) 2 log Likelihood 232 231 230 229 228 l(θˆ) χ 12 (0.95) 2 0.45 0.50 0.55 0.60 0.65 0.70 0.45 0.50 0.55 0.60 0.65 0.70 Theta Theta

Conclusions Summary Fonts are important in plots. Legibility Consistency Special characters Localization When producing mathematical formulas in plots, it is now possible to use the fonts that TEX uses. Even beauty matters

Acknowledgements Fonts used in this talk The Hershey vector font Gothic English Triplex (originally incorporated from the GNU plotutils package; now distributed as part of R). The Computer Modern PostScript Fonts (Adobe Type 1 format) The AMS PostScript Fonts (Adobe Type 1 format) The Type 1 CM-based fonts for Latin, Greek and Cyrillic, with Latin 1 encodings, from the cm-lgc TEX font package. Other stuff used in this talk The typesetting example used the first paragraph of Zen in the Art of Archery by Herrigel (taken from Jim Heffron s TUGboat article Why TEX? ).