Description Usage Arguments Aesthetics Other parameters Cosmetic Tips Also See Examples
Plot a time series as a horizon plot
1 2 |
mapping |
mapping |
data |
dataframe |
show.legend |
logical |
inherit.aes |
logical |
na.rm |
logical |
bandwidth |
bandwith |
... |
other functions A horizon plot breaks the Y dimension down using colours. This is useful when visualising y values spanning a vast range and / or trying to highlight outliers without losing context of the rest of the data. Horizon plots are best viewed in an apsect ratio of very low vertical length. |
x, y, fill. Fill argument is overridden internally but is required for ggplot to assign a colour / fill scale.
bandwidth, to dictate the span of a band.
The minimalist look can be achieved by appending the
following chunk of code to the output object:
+
xlab(NULL) +
ylab(NULL) +
scale_fill_continuous(low = 'green', high = 'red') +
theme(
axis.text = element_blank(),
axis.ticks = element_blank(),
legend.position = 'none',
strip.background = element_blank(),
# strip.text = element_blank(), # useful if only one year of data
plot.background = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank(),
panel.border = element_blank()
)
ggplot_horizon
, a more polished but less
flexible alternative.
1 2 3 4 5 6 7 8 9 10 | {
library(ggplot2)
ggplot(data.frame(x = 1:89, y = as.numeric(unlist(austres))), aes(x =x, y = y, fill = y) )+
stat_horizon() +
scale_fill_continuous(low = 'white', high = 'red')
set.seed(10)
ggplot(data.frame(x = 1:1000, y = cumsum(rnorm(1000))), aes(x =x, y = y, fill = y) )+
stat_horizon() +
scale_fill_continuous(low = 'white', high = 'red')}
|
Loading required package: ggplot2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.