简体   繁体   中英

How to display dates in a QCC Xbar chart

I have qcc chart that is working, but I would like to show the true dates for the values in the control chart instead of showing the value index number

I came across the post below, but I have been unable to apply it to my code. Adding line to plot in qcc Control Chart

Below is my R QCC code:

install.packages("qcc")
install.packages("ggQC")    
library(qcc)
library(ggQC)


date= seq(as.Date("2000/1/1"), by = "month", length.out = 20)
values = c( 
  2.92,    3.16,    2.88,    2.90,    2.92,
  2.94,    2.96,    2.98,    3.02,    2.67,
  3.09,    3.07,    3.04,    3.06,    3.05,
  3.03,    3.07,    2.91,    3.07,    3.30
)

exampl_data <- data.frame(ScrewID , values)
str(exampl_data)

qcc(exampl_data$values, type = "xbar.one", plot = True)

I would like the x axis of the qcc chart to display the dates in the format "jan-2019"/mmyy.

Thank you

Group labels can be added to a qcc plot by providing the labels argument.

Since you did not share the contents of ScrewID , I'm using date as the first observation:

> exampl_data <- data.frame(date , values)
> exampl_data
         date values
1  2000-01-01   2.92
2  2000-02-01   3.16
3  ...

The following code produces the plot below:

qcc(exampl_data$values,
  labels = format(exampl_data$date, "%b-%Y"),
  type = "xbar.one")

在此处输入图片说明

Optionally, use axes.las to change the labels' text orientation (note that due to the limited space, I removed the x axis label with xlab = "" ):

qcc(exampl_data$values,
  labels = format(exampl_data$date, "%b-%Y"),
  type = "xbar.one",
  axes.las = 2,
  xlab = "")

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM