Recent Releases of scales
scales - scales 1.4.0
- Range training now supports custom classes. Continuous classes require a
range()method that returns numeric values. Discrete classes require alevels()method (and optionally adroplevels()method) (#480). - New
label_glue()labelling function for interpolated strings (#457). fullseq()and by extensionbreaks_width()can now deal with unsorted ranges (#435).- New
label_date_short(leading)argument to replace leading zeroes (#442) breaks_pretty()will return the input limit when it has no range (#446)breaks_exp()now provides more sensible breaks for the exponential transformtransform_exp()now has more sensible breaks, available inbreaks_exp()(@teunbrand, #405).- The scales package now keeps track of known palettes. These can be retrieved
using
get_palette()or registered usingset_palette()(#396). label_log()has asignedargument for displaying negative numbers (@teunbrand, #421).- New
label_dictionary()for named lookup of labels (#458). - New function
compose_label()to chain together label formatting functions (#462) - Palette function now have classes, attributes and coercion methods (@teunbrand, #426).
- Added colour manipulation functions:
col_shift(),col_saturate(),col_darker(),col_lighter()andcol_mix()(@teunbrand, #423) label_date_short()gainstzandlocaleargument (#478)
- R
Published by thomasp85 10 months ago
scales - scales 1.3.0
Better type support
rescale(I(x), ...)andrescale_mid(I(x), ...)returnI(x)unaltered (@teunbrand, #403).- Add a rescale method for
difftimeobjects (#382) - Add better support for
difftimeobjects.label_timespan()adds functionality for adding correct unit suffix to timespan data,breaks_timespan()adds functionality for finding pleasant breakpoints across the various bases in time units, whiletransform_timespan()wraps it all together and provides an alternative totransform_hms()(#212)
Ranges
train_continuous()coercesnewto numeric before calculating range (@teunbrand, #369).- Training on factor data no longer sorts the range after multiple training
passes if the new
fctargument oftrain_discrete()is used (#383) - The
DiscreteRangeclass now keeps track on whether it has been trained on factor data. - Attempt to make the sort behavior of the range consistent for character vectors during training. Mixing of character and factor data will make the factor level order take precedence no matter if the training starts with a charactor vector
Transformations
- Transformation function have been renamed to
transform_*-prefixed names instead of*_trans-suffixed names. This allows for a better tab-completion search of transformations. The S3 class of transformations has been renamed from"trans"to"transform".new_transform()replacestrans_new()andtrim_to_domain()replacestrans_range(). All old functions are kept for posterity. transform_sqrt()no longer returns an inverse for values outside of its domain (#214)- Add an inverse (area) hyperbolic sine transformation
transform_asinh(), which provides a logarithm-like transformation of a space, but which accommodates negative values (#297) - Correct the domain calculation for
transform_compose()(@mjskay, #408). - Transformation objects can optionally include the derivatives of the transform and the inverse transform (@mjskay, #322).
Misc
- The
scale_cutargument innumber()now works as advertised for values below the lowest cut value (#346) scale_cutwill now choose a more appropriate cut in the case of the first cut creating an irrational-ish number.- Added a new option to the
style_positiveargument inlabel_*()functions. Setting this to"space"will add a figure space in front of the number to make it easier to align positive and negative values as figure space takes up the same amount of space as-(#366) label_dollar()has been superseeded bylabel_currency()for clarity (#344)- Palette functions now have the
pal_-prefix. The old_pal-suffixed versions are kept for backward compatibility.
- R
Published by thomasp85 about 2 years ago
scales - scales 1.2.1
- Re-document to fix HTML issues in
.Rd.
- R
Published by hadley over 3 years ago
scales - scales 1.2.0
New features
label_number():- New
style_positiveandstyle_negativeargument control how positive and negative numbers are styled (#249, #262). - The
prefixcomes after the negative sign, rather than before it, yielding (e.g) the correct-$1instead of$-1. - New
scale_cutargument enables independent scaling of different parts of the range. This is useful inlabel_dollar()to support scaling of large numbers by suffix (e.g. "M" for million, "B" for billion). It can be used withcut_short_scale()when billion = thousand million andcut_long_scale()when billion = million million (initial implementation provided by @davidchall). Additionally, the accuracy is now computed per scale category, so rescaled values can have different numbers of decimal places (#339). label_number_si()is deprecated because it previously used short scale abbreviations instead of the correct SI prefixes. You can mimic the previous results withlabel_number(scale_cut = cut_scale_short())or get real SI labels withlabel_number(scale_cut = cut_SI("m"))(#339, with help from @davidchall).
- New
label_bytes()now correctly accounts for thescaleargument when choosing auto units (@davidchall, #235).label_date()andlabel_time()gain alocaleargument that allows you to set the locale used to generate day and month names (#309).New
label_log()displays the base and a superscript exponent, for use with logarithmic axes (@davidchall, #312).New
compose_trans()allows arbitrary composition of transformers. This is mostly easily achieved by passing a character vector whenever you might previously have passed the name of a single transformer. For example,scale_y_continuous(trans = c("log10", "reverse"))will create a reverse log-10 scale (#287).
Bug fixes and minor improvements
breaks_width()now supports units like"3 months"in theoffsetargument.col_quantile()no longer errors if data is sufficiently skewed that we can't generate the requested number of unique colours (#294).dollar(negative_parens)is deprecated in favour ofstyle_negative = "parens".hue_pal()respectsh.startonce again (#288).label_number_auto()correctly formats single numbers that are greater than 1e+06 without an error (@karawoo, #321)manual_pal()now always returns an unnamed colour vector, which is easy to use withggplot2::discrete_scale()(@yutannihilation, #284).time_trans()anddate_trans()havedomainsof the correct type so that they can be transformed without error (#298).Internal
precision(), used whenaccuracy = NULL, now avoids displaying unnecessary digits (@davidchall, #304).
- R
Published by hadley almost 4 years ago
scales - scales 1.1.1
breaks_width()now handlesdifftime/hmsobjects (@bhogan-mitre, #244).hue_pal()now correctly inverts color palettes whendirection = -1(@dpseidel, #252).Internal
precision(), used whenaccuracy = NULL, now does a better job when duplicate values are present (@teunbrand, #251). It also does a better job when there's a mix of finite and non-finite values (#257).New
oob_keep()to keep data outside range, allowing for zoom-limits whenoob_keepis used asoobargument in scales. Existing out of bounds functions have been renamed with theoob_-prefix to indicate their role (@teunbrand, #255).ordinal_french()gainspluralandgenderarguments (@stephLH, #256).
- R
Published by hadley almost 6 years ago
scales - scales 1.1.0
Axis breaks and labels have a new naming scheme: functions that generate breaks from limits are called
breaks_; functions that generate labels from breaks are calledlabels_(#226).All breaks and labels examples have been overhauled to use new
demo_continuous(),demo_discrete(), anddemo_log10(), so you can see how to use scales functions with ggplot2.
Labels
All label functions preserve names (#202) and keep
NAs asNAs instead of
trying to convert to"NA"(@clauswilke, #187).New
label_bytes()replacesnumber_bytes_format()with a more
convenient interface. It takes a singleunitargument which can either be an SI unit (e.g. "kB"), a binary unit (e.g. "kIB"), or an automatic unit (either "autosi" or "autobinary").It always uses "B" as the symbol for bytes (#174), and checks that
units
are valid. Additionally, auto units are now used to determine the symbol separately for each value (@mikmart):```R labelbytes("autobinary")(1024^(1:3))
> [1] "1 kiB" "1 MiB" "1 GiB"
```
New
label_date_short()creates labels for a date axis that only show the
components of the date that have changed since the previous label. For example, if you have Jan 10, Jan 20, Jan 30, and Feb 1,
label_date_short()will use labels Jan 10, 20, 30, Feb 1 (#209).label_dollar()now correctly formats negative numbers as (e.g.) -$200
(#216).label_math()now returns an expression vector, and doesn't coerce inputs to names.label_number()takesscaleinto account when computingaccuracy, if not
supplied. This means thatlabel_percent()should have better default
accuracy in many cases (#192).label_number()now picks the accuracy automatically by default. The
underlying heuristic has been improved to use the distance between adjacent
breaks (rather than the total range of the break).New
label_number_auto()automatically picks betweennumber_format()and
scientific_format()based on the range of the input. It should produce nice
output over a very wide range of inputs (@paleolimbot, #208).New
label_number_si()formats numeric vectors with limited SI units. Individual values are scaled and labelled with abbreviations "K", "M", "B", or "T" dependent on magnitude (@dpseidel, #83).label_parse()now generates an expression object that can be used to
display formatted labels in ggplot2 (@agila5, #203).label_pvalue()now reports values close to 1 (as determined byaccuracy)
as (e.g.) ">0.99". You can control the prefixes used with the new
prefixargument (#213).
Breaks
The built in breaks functions now returns a function that takes both a range
and a desired number of breaks, making it possible to overwrite the defaults number of desired breaks given in the constructor call (@thomasp85).breaks_log()has nicer behaviour when there are no finite inputs (#210). It also provides usable breaks even with very small ranges (@billdenney, #168)New
breaks_width()which allows you to specify a fixed distance between breaks (along with optional offset).
Transformations
New
yj_trans()implements the Yeo-Johnson transformation (@zamorarr, #196)transobjects gets methods forplot()andlines(), and all numeric
transformations get an example showing the transformation.boxcox_trans()no longer throws an error when given NA values
(@sflippl, #181).
Other bug fixes and minor improvements
scales now uses the farver package for colour manipulation instead of a
combination of grDevices and hand-rolled C++ code (#223).alpha()now preserves element names (@wibeasley, #195)ContinuousRangeandDiscreteRangemethods now properly inherit and are
fully mutable (@dpseidel).col_numeric(),col_bin(),col_quantile(), andcol_factor()now support viridis colors. Just pass a palette name ("magma","inferno","plasma", or"viridis") as thepaletteargument (@jcheng5, #191).col_numeric(),col_bin(),col_quantile(), andcol_factor()now have areverseparameter, to apply color palettes in the opposite of their usual order (i.e. high-to-low instead of low-to-high) (@jcheng5, #191).col_bin()andcol_quantile()now take arightargument, which is passed tobase::cut(); it indicates whether the bin/quantile intervals should be closed on the right (and open on the left), or vice versa (@jcheng5, #191).col_factor()now tries to avoid interpolating qualitative RColorBrewer palettes. Instead, it attempts to assign a palette color to each factor level. Interpolation will still be used if there are more factor levels than available colors, and a warning will be emitted in that case (@jcheng5, #191).dichromat_pal()documentation now builds without requiring suggested
dichromatpackage to be installed (@dpseidel, #172).date_breaks()now supports subsecond intervals (@dpseidel, #85).
- R
Published by hadley over 6 years ago
scales - scales 1.0.0
New Features
Formatters
comma_format(),percent_format()andunit_format()gain new arguments:accuracy,scale,prefix,suffix,decimal.mark,big.mark(@larmarange, #146).dollar_format()gains new arguments:accuracy,scale,decimal.mark,trim(@larmarange, #148).New
number_bytes_format()andnumber_bytes()format numeric vectors into byte measurements (@hrbrmstr, @dpseidel).New
number_format()provides a generic formatter for numbers (@larmarange, #142).New
pvalue_format()formats p-values (@larmarange, #145).ordinal_format()gains new arguments:prefix,suffix,big.mark,rules; rules for French and Spanish are also provided (@larmarange, #149).scientific_format()gains new arguments:scale,prefix,suffix,decimal.mark,trim(@larmarange, #147).New
time_format()formatsPOSIXtandhmsobjects (@dpseidel, #88).
Transformations & breaks
boxcox_trans()is now invertible forx >= 0and requires positive values. A new argumentoffsetallows specification of both type-1 and type-2 Box-Cox transformations (@dpseidel, #103).log_breaks()returns integer multiples of integer powers of base when finer breaks are needed (@ThierryO, #117).New function
modulus_trans()implements the modulus transformation for positive and negative values (@dpseidel).New
pseudo_log_trans()for transforming numerics into a signed logarithmic scale with a smooth transition to a linear scale around 0 (@lepennec, #106).
Minor bug fixes and improvements
scales functions now work as expected when it is used inside a for loop. In previous package versions if a scales function was used with variable custom parameters inside a for loop, some of the parameters were not evaluated until the end of the loop, due to how R lazy evaluation works (@zeehio, #81).
colour_ramp()now usesalpha = TRUEby default (@clauswilke, #108).date_breaks()now supports subsecond intervals (@dpseidel, #85).Removes
dichromatandplyrdependencies.dichromatis now suggested (@dpseidel, #118).expand_range()argumentsmulandaddnow affect scales with a range of 0
(@dpseidel, ggplot2-2281).extended_breaks()now allows user specification of thelabeling::extended()argumentonly.looseto permit more flexible breaks specification (@dpseidel, #99).New
rescale()andrescale_mid()methods supportdistobjects (@zeehio, #105).rescale_mid()now properly handles NAs (@foo-bar-baz-qux, #104).
- R
Published by hadley over 7 years ago
scales - scales 0.5.0
- New function
regular_minor_breaks()calculates minor breaks as a property of the transformation. - Adds
viridis_pal()for creating palettes with color maps from the viridisLite package. - Switched from reference classes to R6.
rescale()andrescale_mid()are now S3 generics, and work withnumeric,Date,POSIXct,POSIXltandbit64::integer64objects.
- R
Published by karawoo over 8 years ago
scales - scales 0.4.1
extended_breaks()no longer fails on pathological inputs- New
hms_trans()for transforming hms time vectors. train_discrete()gets a newna.rmargument which controls whetherNAs are preserved or dropped.
- R
Published by hadley over 9 years ago
scales - scales 0.4.0
- Switched from
NEWStoNEWS.md manual_pal()produces a warning if n is greater than the number of values in the palette (@jrnold, #68).precision(0)now returns 1, which meanspercent(0)now returns 0% (#50).scale_continuous()uses a more correct check for numeric values.- NaN is correctly recognised as a missing value by the gradient palettes (ggplot2#1482).
- R
Published by hadley almost 10 years ago
scales - scales 0.3.0
rescale()preserves missing values in input when the range ofxis (effectively) 0 (ggplot2#985).- Continuous colour palettes now use
colour_ramp()instead ofcolorRamp(). This only supports interpolation in Lab colour space, but is hundreds of times faster.
- R
Published by hadley over 10 years ago
scales - scales 0.2.5
Improved formatting functions
date_format()gans an option to specify time zone (#51).dollar_format()is now more flexible and can add either prefixes or suffixes for different currencies (#53). It gains anegative_parensargument to show negative values as($100)and now passes missing values through unchanged (#40, @dougmitarotonda).- New
ordinal_format()generates ordinal numbers (1st, 2nd etc) (@aaronwolen, #55) - New
unit_format()makes it easier to add units to labels, optionally scaling (@ThierryO, 46) - New
wrap_format()function to wrap character vectors to a desired width. (@jimhester, #37).
New colour scaling functions
- New color scaling functions
col_numeric(),col_bin(),col_quantile(), andcol_factor(). These functions provide concise ways to map continuous or categorical values to color spectra. - New
colour_ramp()function for performing color interpolation in the CIELAB color space (likegrDevices::colorRamp(space = 'Lab'), but much faster).
Other bug fixes and minor improvements
boxcox_trans()returns correct value when p is close to zero (#31).dollar()andpercent()both correctly return a zero length string for zero length input (@BrianDiggs, #35)brewer_pal()gains adirectionargument to easily invert the order of colours (@jiho, #36).show_col()has additional options to showcase colors better (@jiho, #52)- Relaxed tolerance in
zero_range()to.Machine$double.eps * 1000(#33).
- R
Published by hadley over 10 years ago