How to remove box and whiskers from plot() function in R? - r

I'm trying to do a very simple plot using the plot() function in R where I plot out the weights and diets of chicks in a stratified plot. For other simple plots like this I've been able to just use the plot() function and it's gone fine. But for some reason, R insists on plotting this as a box-and-whiskers chart instead of plotting all the values themselves. I've tried many different solutions I've found on the Web, from box=FALSE to box=0 to bty="n" to type="p" but nothing works. R always plots it as a box-and-whiskers chart. I can use whisklty=0 to get rid of the whiskers, but nothing I've tried (including all possible combinations of the above solutions) will replace the boxes with the actual values I want.

If the x-axis data is categorical, plot will return a boxplot by default. You could run plot.default() instead of plot() and that will give you a plot of points.
Compare, for example:
plot(iris$Species, iris$Petal.Width)
plot.default(iris$Species, iris$Petal.Width)
If you type methods(plot) in the console, you'll see all of the different kinds of plots the plot function returns, depending on what type of object you give it. plot.default is the "method" that gets dispatched when you provide plot with two columns of numbers. plot.factor gets dispatched when the y-values are numeric and the x-values are categorical (run ?plot.factor for details). If you do plot(table(mtcars$vs, mtcars$cyl)) the plot.table method gets dispatched. And so on.

Related

How do I plot a scatterplot graph with a repeated-measures variable and a continuous variable in r?

I have a four levels repeated measures variable (let's call it RM) and I have a continuous variable predictor (let's call it C).
I want to plot a scatterplot graph with C on the X-Axis and RM on the Y-Axis with different lines within the plot for each level of RM.
Is this possible to do with ggplot or a similar package?
Thanks in advance!
Utilizing ggplot2, you should be able to achieve this type of graphical output. Viewing a portion of your data that you wish to plot would be beneficial to provide a sufficient answer.
I have attached a link to a summary of ggplot2 graphical functions here. This link provides some background on ggplot2 and the components necessary to create a graph. Three components are needed in ggplot2 to make a graph, the data, the ggplot2 function, and mapping your variables with the aesthetic.
Because you don't have a representation of some of your data, providing a sufficient answer is difficult, but it might look something like this.
ggplot(data=yourdata, aes(x= C(continuous_variable, y = RM(repeated_measures)) +
geom_point()
You may also map geom_line for each RM variable in addition to this example. Hope this helps!

Plotting GAMM model results with package gratia

Is there a way to produce plots with gratia that have the y-axis on the response variable scale similar to the scale="response" visreg function? I know scale is already an option for the y-axis in gratia, but just for axis range and not transforming the variable.
Thinking of something like:
draw(mymodel, type="response")?
This is a current feature request for the package: https://github.com/gavinsimpson/gratia/issues/79
If I ever surface from creating content for two new courses this semester adding this is a top priority for me.
Currently the best I can suggest is to evaluate the smooth using evaluate_smooth(), then use mutate() to apply the inverse of the link function to the estimated value and the confidence interval, and then use the draw() method for those objects to produce the plot, with cowplot or patchwork to plot multiple plots on a single page/device.

Plotting multiple species accumulation curves in R

I am trying to plot multiple curves on one plot. I have managed to produce the curves individually but can't get them all on the same plot.
I have tried the add=TRUE function which isn't working.
When using this line of code
caw<- plot(specaccum(cs, method = "exact"))
Nothing is saving to the data section on the right. It's just saying NULL (empty). Which could be the issue but I am unsure how to move forward?

Box plots, plots in octave

I'm new to Octave, so there are many confusing things for me, and I've never done computer programming before so most of the language is also confusing.
I have sets of data c_o, m_o, y_o, k_o as 144 x 1 matrices (column vectors?)
Box plots
Using examples I found online, I wrote this:
axis ([0,5]);
boxplot (c_o, m_o, y_o, k_o);
set(gca (), "xtick", [1,2,3,4], "xticklabel", {"cyan", "magenta", "yellow", "key"});
However, it results in an error
Boxplot.m: grouping vector may only be passed as second arg
I have no idea what this means.
Plots
I'm trying to figure out how to plot multiple data sets with different colors.
For example,
figure (1); plot (c_o , "c");
works perfectly fine.
However, I'd like to remove the horizontal axis, change the horizontal axis from [0,200] to [0,150] , and plot multiple sets of data on the same plot (not multiple plots in the same figure, but the different data on the same set of axis). I haven't been able to find out how, though.
For the record, I do know that there are probably other programming languages more suited for statistical analysis; it just so happens that my first use of this happened to be statistical in nature.

R statistics: Drawing multiple plots in RGL

Does anyone know how to draw multiple 3d plots in one picture using RGL in R Statistics.
I have three variables and each of those variables belong to two groups. I want each group to have a different color so I can visualize it. In regular R stats, I just use subset and then use par(new=T). I haven't seen anything equivalent for the 3d plot. Does anyone have any suggestion?
Thanks!
try plot3d(x, y, z, add=TRUE)
Admittedly I was a bit surprised when it worked, I thought it would throw an error on the first plot, but i guess it creates an existing plot if none exists and otherwise adds the points to the existing plot

Resources