Scale.x_discrete

Scale.x_discrete

Map data categorical to Cartesian coordinates. Unlike Scale.x_continuous, each unique x value will be mapped to a equally spaced positions, regardless of value.

By default continuous scales are applied to numerical data. If data consists of numbers specifying categories, explicitly adding Scale.x_discrete is the easiest way to get that data to plot appropriately.

Arguments

Aesthetics Acted On

x, xmin, xmax, xintercept

Examples

# Treat numerical x data as categories
plot(x=rand(1:3, 20), y=rand(20), Scale.x_discrete)
x 2 3 1 0.0 0.5 1.0 y
# To perserve the order of the columns in the plot when plotting a DataFrame
df = DataFrame(v1 = randn(10), v2 = randn(10), v3 = randn(10))
plot(df, x=Col.index, y=Col.value, Scale.x_discrete(levels=df.colindex.names))
x v1 v2 v3 -2 -1 0 1 2 3 y