I like using the R package qcc. This is a great package for the quality control professional. The package generates a lot of cool graphics. I know how to modify basic graphs in R with the par() command.
The graphics in the qcc package are somewhat unique and I don't always know what elements make up the graphics. How do I determine what elements make up the graphics so I can modify them with the par() commands and arguments. Take this simple cause and effect diagram in the code below. How would I go about modifying line colors, line thicknesses, font, etc? I have no idea how the author constructed this when they developed the package.
library(qcc)
cause.and.effect(cause=list(Measurements=c("Micrometers", "Microscopes", "Inspectors"),
Materials=c("Alloys", "Lubricants", "Suppliers"),
Personnel=c("Shifts", "Supervisors", "Training", "Operators"),
Environment=c("Condensation", "Moisture"),
Methods=c("Brake", "Engager", "Angle"),
Machines=c("Speed", "Lathes", "Bits", "Sockets")),
effect="Surface Flaws")
The following capability analysis should be a little more familiar to the normal R user. How do I modify the three vertical red lines in this graphic? Perhaps I want to use a different color, different line style/thickness, etc. And again, how do I determine what elements make up the graphic so I can modify any particular part of it if I so wish?
library(qcc)
data(pistonrings)
attach(pistonrings)
diameter <- qcc.groups(diameter, sample)
q <- qcc(diameter[1:25,], type="xbar", nsigmas=3, plot=FALSE)
process.capability(q, spec.limits=c(73.95,74.05))
Related
I would need create a chart like the one on the picture. I don't want to draw it by hand, since I need more of them. I prefer R CRAN for drawing charts, but would do also any other programming or plotting program. If possible pdf or eps outputs are preferable. Does anybody have an idea, what type of chart, or which R (or other SW) package would support something like that?
I have found the solution. Orange software package makes the charts.
https://docs.orange.biolab.si/3/data-mining-library/reference/evaluation.cd.html
I would like to produce a series of plots in both high-resolution and low-resolution versions, or stated differently using two different file types (.png and .eps). I'd like to know the best/least repetetive way to do this. I am using the gplot function in sna, and the plot has a custom legend outside the plot area. I wrote a function something like this:
library(sna)
plotfun <- function(net){
png("test.png",width=800)
p <- gplot(net)
par(xpd=T)
legend(max(p[,1])+1,max(p[,2]),legend=letters[1:10],title="custom legend")
dev.off()
seteps()
postscript(test.eps)
#repeat all the plotting commands, which are much longer in real life
dev.off()
}
#try it with some random data
plotfun(rgraph(10))
This is perfectly functional but seems inefficient and clumsy. The more general version of this question is: if for any reason I want to create a plot (including extra layers like my custom legend), store it as an object, and then plot it later, is there a way to do this? Incidentally, this question didn't seem sna specific to me at first, but in trying to reproduce the problem using a similar function with plot, I couldn't get the legend to appear correctly, so this solution to the outside-the-plot-area legend doesn't seem general.
I would recommend generate graphs only in Postscript/PDF from R and then generate bitmaps (e.g. PNG) from the Postscript/PDF using e.g. ImageMagick with -density parameter (http://www.imagemagick.org/script/command-line-options.php#density) set appropriately to get desired resolution. For example
convert -density 100 -quality 100 picture.pdf picture.png
assuming picture.pdf is 7in-by-7in (R defaults) will give you a 700x700 png picture.
With this approach you will not have to worry that the picture comes out formatted differently depending which R device (pdf() vs png()) is used.
Good day everyone. I have a question concerning ggobi and rggobi package. I am using R version 2.13.2 and Ubuntu 11.04. I am new to ggobi and I'm reading the book Interactive and Dynamic Graphics for Data Analysis. The book was published 2007.
My question is: how can I export a graph for rggobi to pdf to include it in latex. For example: I have lots of variables in ggobi and I need to export the ggplot like scatterplot of any two variables or parallel cordinates graph to a pdf. So far I've read that the authors suggests to solve it like this:
library(DescribeDisplay)
d <- dd_load("fig.R")
plot(d)
or
p <- ggplot(d)
print(p)
which produces nice graphics which you can use with pdf() function.
But neither the DescribeDisplay package, nor ggplot are available in 2.13.2.
I browsed the web for solution, but I found only that ggobi_display_save_picture() could be useful for image graphs but not for pdf. I also tried save display description (tools->save display description) and then plotting it with qplot() or plot(). But all I get is a blank screen while ggobi_display_save_picture() gives a good picture. There is probably a much easier solution since R is changing and becoming more convenient to use.
I am trying to render 739455 data point on a graph using R, but on the x-axis I can not view all those numbers, is there a way I can do that?
I am new to R.
Thank you
As others suggested, try hist, hexbin, plot(density(node)), as these are standard methods for dealing with more points than pixels. (I like to set hist with the parameter breaks = "FD" - it tends to have better breakpoints than the default setting.)
Where you may find some joy is in using the iplots package, an interactive plotting package. The corresponding commands include ihist, iplot, and more. As you have a Mac, the more recent Acinonyx package may be even more fun. You can zoom in and out quite easily. I recommend starting with the iplots package as it has more documentation and a nice site.
If you have a data frame with several variables, not just node, then being able to link the different plots such that brushing points in one plot highlights them in another will make the whole process more stimulating and efficient.
That's not to say that you should ignore hexbin and the other ideas - those are still very useful. Be sure to check out the options for hexbin, e.g. ?hexbin.
I am wondering if in R there is a per-existing package that can colorate sets inside graph or a package that can generate a list of colors that are not close,
Because I have a graph that have many clusters and I want to color but I don't want to colors to be close.
I have found a nice answer here but I am wondering if there is a per-existing package for
You may also want to check out the package RColorBrewer for other built in color palettes. However, you may run into issues if you need large numbers of colours. There is a nice post on CrossValidated which addresses the large n issue and offers a few nice solutions as well. Specifically, would it make sense to facet your plot based on some large groupings? Do you need to plot all of the items at once? ggplot2 makes it easy to facet based on a column in your data. I'm sure there are equivalent functions in base graphics and lattice, but I'm not as familiar with them.
See the functions rainbow, heat.colors, terrain.colors etc, described in the help pages (?rainbow). These are part of the grDevices package, which is installed by default.