Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bar Plot x-axis order in R ggvis

Tags:

r

bar-chart

ggvis

I am experimenting to use ggvis for my daily report. One issue I came across is that for a dataset that I intended to plot x-axis as in the data order. However, the actual plot shows up in the alphabet order.

Is there any hidden parameters to change x-axis order for Bar chart in R?

Step    LER
Pre 3.2
DS  2.8
SiARC   2.2
OPL 1.9
ILD 1.6
Oxide   1.5

library(ggvis)
ler <- read.csv("shinyapps/EUV/data/by_step_LER.csv")
ler %>% ggvis(x = ~Step, y = ~LER) %>% layer_bars()
like image 294
Rick Avatar asked Dec 30 '25 15:12

Rick


1 Answers

library(ggvis)

ler <- structure(list(Step = structure(1:6, .Label = c("Pre", "DS", "SiARC", "OPL", "ILD", "Oxide"), class = "factor"), LER = c(3.2, 2.8, 2.2, 1.9, 1.6, 1.5)), .Names = c("Step", "LER"), row.names = c(NA, -6L), class = "data.frame")

ler$Step <- factor(ler$Step, levels = ler$Step)

ler %>% ggvis(x = ~Step, y = ~LER) %>% layer_bars()

enter image description here


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!