# mizani > Scales for Python ## Docs ### API Reference #### Bounds > Continuous variables have values anywhere in the range minus infinite to plus infinite. However, when creating a visual representation of these values what usually matters is the relative difference between the values. This is where rescaling comes into play. The values are mapped onto a range that a scale can deal with. For graphical representation that range tends to be $[0, 1]$ or $[0, n]$, where $n$ is some number that makes the plotted object overflow the plotting area. Although a scale may be able handle the $[0, n]$ range, it may be desirable to have a lower bound greater than zero. For example, if data values get mapped to zero on a scale whose graphical representation is the size/area/radius/length some data will be invisible. The solution is to restrict the lower bound e.g. $[0.1, 1]$. Similarly you can restrict the upper bound -- using these functions. - [bounds.censor](https://has2k1.github.io/mizani/reference/bounds.censor.html) - [bounds.expand_range](https://has2k1.github.io/mizani/reference/bounds.expand_range.html) - [bounds.rescale](https://has2k1.github.io/mizani/reference/bounds.rescale.html) - [bounds.rescale_max](https://has2k1.github.io/mizani/reference/bounds.rescale_max.html) - [bounds.rescale_mid](https://has2k1.github.io/mizani/reference/bounds.rescale_mid.html) - [bounds.squish_infinite](https://has2k1.github.io/mizani/reference/bounds.squish_infinite.html) - [bounds.zero_range](https://has2k1.github.io/mizani/reference/bounds.zero_range.html) - [bounds.expand_range_distinct](https://has2k1.github.io/mizani/reference/bounds.expand_range_distinct.html) - [bounds.squish](https://has2k1.github.io/mizani/reference/bounds.squish.html) #### Breaks > All scales have a means by which the values that are mapped onto the scale are interpreted. Numeric digital scales put out numbers for direct interpretation, but most scales cannot do this. What they offer is named markers/ticks that aid in assessing the values e.g. the common odometer will have ticks and values to help gauge the speed of the vehicle. The named markers are what we call breaks. Properly calculated breaks make interpretation straight forward. These functions provide ways to calculate good(hopefully) breaks. - [breaks.breaks_log](https://has2k1.github.io/mizani/reference/breaks.breaks_log.html) - [breaks.breaks_symlog](https://has2k1.github.io/mizani/reference/breaks.breaks_symlog.html) - [breaks.minor_breaks](https://has2k1.github.io/mizani/reference/breaks.minor_breaks.html) - [breaks.minor_breaks_trans](https://has2k1.github.io/mizani/reference/breaks.minor_breaks_trans.html) - [breaks.breaks_date](https://has2k1.github.io/mizani/reference/breaks.breaks_date.html) - [breaks.breaks_date_width](https://has2k1.github.io/mizani/reference/breaks.breaks_date_width.html) - [breaks.breaks_width](https://has2k1.github.io/mizani/reference/breaks.breaks_width.html) - [breaks.breaks_timedelta](https://has2k1.github.io/mizani/reference/breaks.breaks_timedelta.html) - [breaks.breaks_timedelta_width](https://has2k1.github.io/mizani/reference/breaks.breaks_timedelta_width.html) - [breaks.breaks_extended](https://has2k1.github.io/mizani/reference/breaks.breaks_extended.html) #### Labels > Scales have guides and these are what help users make sense of the data mapped onto the scale. Common examples of guides include the x-axis, the y-axis, the keyed legend and a colorbar legend. The guides have demarcations(breaks), some of which must be labelled. The `label_*` functions below create functions that convert data values as understood by a specific scale and return string representations of those values. Manipulating the string representation of a value helps improve readability of the guide. - [labels.cut_bytes](https://has2k1.github.io/mizani/reference/labels.cut_bytes.html) - [labels.cut_long_scale](https://has2k1.github.io/mizani/reference/labels.cut_long_scale.html) - [labels.cut_short_scale](https://has2k1.github.io/mizani/reference/labels.cut_short_scale.html) - [labels.cut_si](https://has2k1.github.io/mizani/reference/labels.cut_si.html) - [labels.cut_time_scale](https://has2k1.github.io/mizani/reference/labels.cut_time_scale.html) - [labels.label_comma](https://has2k1.github.io/mizani/reference/labels.label_comma.html) - [labels.label_custom](https://has2k1.github.io/mizani/reference/labels.label_custom.html) - [labels.label_currency](https://has2k1.github.io/mizani/reference/labels.label_currency.html) - [labels.label_dollar](https://has2k1.github.io/mizani/reference/labels.label_dollar.html) - [labels.label_percent](https://has2k1.github.io/mizani/reference/labels.label_percent.html) - [labels.label_scientific](https://has2k1.github.io/mizani/reference/labels.label_scientific.html) - [labels.label_date](https://has2k1.github.io/mizani/reference/labels.label_date.html) - [labels.label_date_short](https://has2k1.github.io/mizani/reference/labels.label_date_short.html) - [labels.label_number](https://has2k1.github.io/mizani/reference/labels.label_number.html) - [labels.label_log](https://has2k1.github.io/mizani/reference/labels.label_log.html) - [labels.label_timedelta](https://has2k1.github.io/mizani/reference/labels.label_timedelta.html) - [labels.label_pvalue](https://has2k1.github.io/mizani/reference/labels.label_pvalue.html) - [labels.label_ordinal](https://has2k1.github.io/mizani/reference/labels.label_ordinal.html) - [labels.label_bytes](https://has2k1.github.io/mizani/reference/labels.label_bytes.html) #### Palettes > Palettes are the link between data values and the values along the dimension of a scale. Before a collection of values can be represented on a scale, they are transformed by a palette. This transformation is knowing as mapping. Values are mapped onto a scale by a palette. Scales tend to have restrictions on the magnitude of quantities that they can intelligibly represent. For example, the size of a point should be significantly smaller than the plot panel onto which it is plotted or else it would be hard to compare two or more points. Therefore palettes must be created that enforce such restrictions. This is the reason for the `*_pal` functions that create and return the actual palette functions. - [palettes.hls_palette](https://has2k1.github.io/mizani/reference/palettes.hls_palette.html) - [palettes.hsluv_palette](https://has2k1.github.io/mizani/reference/palettes.hsluv_palette.html) - [palettes.rescale_pal](https://has2k1.github.io/mizani/reference/palettes.rescale_pal.html) - [palettes.area_pal](https://has2k1.github.io/mizani/reference/palettes.area_pal.html) - [palettes.abs_area](https://has2k1.github.io/mizani/reference/palettes.abs_area.html) - [palettes.grey_pal](https://has2k1.github.io/mizani/reference/palettes.grey_pal.html) - [palettes.hue_pal](https://has2k1.github.io/mizani/reference/palettes.hue_pal.html) - [palettes.brewer_pal](https://has2k1.github.io/mizani/reference/palettes.brewer_pal.html) - [palettes.gradient_n_pal](https://has2k1.github.io/mizani/reference/palettes.gradient_n_pal.html) - [palettes.cmap_pal](https://has2k1.github.io/mizani/reference/palettes.cmap_pal.html) - [palettes.cmap_d_pal](https://has2k1.github.io/mizani/reference/palettes.cmap_d_pal.html) - [palettes.desaturate_pal](https://has2k1.github.io/mizani/reference/palettes.desaturate_pal.html) - [palettes.manual_pal](https://has2k1.github.io/mizani/reference/palettes.manual_pal.html) - [palettes.xkcd_palette](https://has2k1.github.io/mizani/reference/palettes.xkcd_palette.html) - [palettes.crayon_palette](https://has2k1.github.io/mizani/reference/palettes.crayon_palette.html) - [palettes.cubehelix_pal](https://has2k1.github.io/mizani/reference/palettes.cubehelix_pal.html) - [palettes.identity_pal](https://has2k1.github.io/mizani/reference/palettes.identity_pal.html) - [palettes.none_pal](https://has2k1.github.io/mizani/reference/palettes.none_pal.html) #### Transforms > *"The Grammar of Graphics (2005)"* by **Wilkinson**, **Anand** and **Grossman** describes three types of transformations. * *Variable transformations* - Used to make statistical operations on variables appropriate and meaningful. They are also used to new variables. * *Scale transformations* - Used to make statistical objects displayed on dimensions appropriate and meaningful. * *Coordinate transformations* - Used to manipulate the geometry of graphics to help perceive relationships and find meaningful structures for representing variations. *Variable* and *scale* transformations are similar in-that they lead to plotted objects that are indistinguishable. Typically, *variable* transformation is done outside the graphics system and so the system cannot provide transformation specific guides & decorations for the plot. The [](`~mizani.transforms.trans`) class is aimed at being useful for *scale* and *coordinate* transformations. - [transforms.asn_trans](https://has2k1.github.io/mizani/reference/transforms.asn_trans.html) - [transforms.atanh_trans](https://has2k1.github.io/mizani/reference/transforms.atanh_trans.html) - [transforms.boxcox_trans](https://has2k1.github.io/mizani/reference/transforms.boxcox_trans.html) - [transforms.modulus_trans](https://has2k1.github.io/mizani/reference/transforms.modulus_trans.html) - [transforms.datetime_trans](https://has2k1.github.io/mizani/reference/transforms.datetime_trans.html) - [transforms.exp_trans](https://has2k1.github.io/mizani/reference/transforms.exp_trans.html) - [transforms.identity_trans](https://has2k1.github.io/mizani/reference/transforms.identity_trans.html) - [transforms.log10_trans](https://has2k1.github.io/mizani/reference/transforms.log10_trans.html) - [transforms.log1p_trans](https://has2k1.github.io/mizani/reference/transforms.log1p_trans.html) - [transforms.log2_trans](https://has2k1.github.io/mizani/reference/transforms.log2_trans.html) - [transforms.log_trans](https://has2k1.github.io/mizani/reference/transforms.log_trans.html) - [transforms.logit_trans](https://has2k1.github.io/mizani/reference/transforms.logit_trans.html) - [transforms.probability_trans](https://has2k1.github.io/mizani/reference/transforms.probability_trans.html) - [transforms.probit_trans](https://has2k1.github.io/mizani/reference/transforms.probit_trans.html) - [transforms.reverse_trans](https://has2k1.github.io/mizani/reference/transforms.reverse_trans.html) - [transforms.sqrt_trans](https://has2k1.github.io/mizani/reference/transforms.sqrt_trans.html) - [transforms.symlog_trans](https://has2k1.github.io/mizani/reference/transforms.symlog_trans.html) - [transforms.timedelta_trans](https://has2k1.github.io/mizani/reference/transforms.timedelta_trans.html) - [transforms.pd_timedelta_trans](https://has2k1.github.io/mizani/reference/transforms.pd_timedelta_trans.html) - [transforms.pseudo_log_trans](https://has2k1.github.io/mizani/reference/transforms.pseudo_log_trans.html) - [transforms.reciprocal_trans](https://has2k1.github.io/mizani/reference/transforms.reciprocal_trans.html) - [transforms.trans](https://has2k1.github.io/mizani/reference/transforms.trans.html) - [transforms.gettrans](https://has2k1.github.io/mizani/reference/transforms.gettrans.html) #### Scale > According to *On the theory of scales of measurement* by **S.S. Stevens**, scales can be classified in four ways -- *nominal*, *ordinal*, *interval* and *ratio*. Using current(2016) terminology, *nominal* data is made up of unordered categories, *ordinal* data is made up of ordered categories and the two can be classified as *discrete*. On the other hand both *interval* and *ratio* data are *continuous*. The scale classes below show how the rest of the Mizani package can be used to implement the two categories of scales. The key tasks are *training* and *mapping* and these correspond to the **train** and **map** methods. To train a scale on data means, to make the scale learn the limits of the data. This is elaborate (or worthy of a dedicated method) for two reasons: - *Practical* -- data may be split up across more than one object, yet all will be represented by a single scale. - *Conceptual* -- training is a key action that may need to be inserted into multiple locations of the data processing pipeline before a graphic can be created. To map data onto a scale means, to associate data values with values(potential readings) on a scale. This is perhaps the most important concept unpinning a scale. The **apply** methods are simple examples of how to put it all together. - [scale.scale_continuous](https://has2k1.github.io/mizani/reference/scale.scale_continuous.html) - [scale.scale_discrete](https://has2k1.github.io/mizani/reference/scale.scale_discrete.html)