JuliaGraphics/Showoff.jl

Name: Showoff.jl

Owner: JuliaGraphics

Description: Nicely format an array of n things for tables and plots

Created: 2016-05-03 11:04:04.0

Updated: 2016-11-22 22:02:10.0

Pushed: 2017-10-01 18:11:57.0

Homepage: null

Size: 33

Language: Julia

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Showoff

Showoff Showoff Build Status Coverage Status

Showoff provides an interface for consistently formatting an array of n things, e.g. numbers, dates, unitful values. It's used in Gadfly to label axes and keys.

It defines a function called showoff that takes an AbstractArray of some type and returns an array of strings of the same length.

If you want your type to look nice when plotted, just define a showoff function. Here's an example.

rt Showoff

table Percent
value::Float64


tion Showoff.showoff(xs::AbstractArray{Percent})
return [string(x, "%") for x in showoff([x.value for x in xs])]

Now we (and more importantly, Gadfly) can print percentages like:

println, showoff([Percent(100 * rand()) for _ in 1:20]))
05943%
55897%
77079%
30976%
23165%
80184%
11683%
18034%
43776%
75979%
10999%
03653%
34161%
84188%
74362%
30227%
98260%
76922%
44115%
7208%

Notice, that compared to show, these all have the same number of digits trailing the ., and look nice when right-aligned.

When no specialized showoff is defined, it falls back on the show function.

This package was originally written by Daniel C. Jones.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.