ggpairs displaying density functions as unfilled lines [closed] - r

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am hoping to just change the diagonal plots to have simple outlines so I can view the overlap of the density functions more clearly but am not having much luck. Here is the code I have been using:
plot_rh <- ggpairs(data_rh[,1:6], mapping = ggplot2::aes(color = Condition_name),
lower = list(combo = wrap(ggally_facethist, bins = 10)),
diag = list(continuous = wrap("densityDiag"), mapping = ggplot2::aes(fill=Condition_name)))
Plot with filled density functions:

Changing aes(fill=Condition_name) to aes(color=Condition_name) should result in unfilled lines.
You could also change it to aes(fill=Condition_name), alpha = 0.4 to make the filled densities semi-transparent which may improve the view.

Related

How to have a horizontal filling areaplot in R [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
Imagine a normal area plot of a continuous function y = f(x), which fills the area below the plotted graph down to the x-axis.
But I have to plot my data transposed. The y-data is now on the horizontal axis and the x-data is now on the vertical axis. I want to have the very same plot as before, just transposed ... so the filling should go left, towards the vertical y-axis.
But I can't find a fitting argument for this in the R documentation of areaplot
Can you help me? Is there a work around?
You can switch the axes just by switching where you use x and y. You can fill the area "under" the curve using polygon. Here is a simple example with the Gaussian distribution.
## Data
x = seq(-3.5,3.5,0.1)
y = dnorm(y)
## Plot
plot(y, x, type="l", xaxs="i", xlim=c(0,0.45))
polygon(y,x, col="gray")

Function in R which gives custom colour (from a given interval) to the borders of a continuous data plot using ggplot2 [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
The function supposed to use colours from the give scale (between low and high) for the border colours if I plot continuous data plot using ggplot2.
> scale_colour_continuous <- function(...) {
> ggplot2::scale_colour_gradient(..., low = "#FFFF00", high = "#3366FF",
> na.value = "#262626", aesthetics = "colour")
Unfortunately, my code above doesn't appear to be working. I find if very interesting, because the same thing for the the fills of the plot works fine with the same arguments (aesthetics = "fill"). What am I missing here?
You don't need to explicitly call ggplot2. If you want to,you could add an if statement that checks if ggplot2 is loaded. This works as required.
my_theme<-function(...){
scale_colour_gradient(..., low = "#FFFF00", high = "#3366FF",
na.value = "#262626", aesthetics = "colour")
}
library(tidyverse)
iris %>%
ggplot(aes(Sepal.Length,Petal.Length,col=Sepal.Length))+
geom_point()+
my_theme()#wanted to make a theme so don't mind the naming.

Plotting in R missing indices in x plot [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am drawing a plot in R as follow:
respCSV=read.csv("R1.csv")
respCol=respCSV[["RESP"]]
plot(respCol,type='o')
when it plot the series, the x axis lable are not countinuous, instead of 1,2,3,4,
it is 1,5,10.how to fix that?
If the issue is that the axis labels are too spare, and your x variable is continuous you can make your own. This works on standard calls to plot and sometimes it works on plots based on it, but not always.
plot(x, y, xaxt = 'n') # get rid of the default x-axis
axis(1, at = 1:10, values = 1:10) # put the values you want.
Note that there may be other reasons why your axis labels aren't showing up. If the x-axis isn't continuous, the solution will be different.

R - what is the best way to plot multiple functions $y=cx$ where c is a parameter [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to plot the function y=cx depending on c. It is going to be number of lines going through the point (0,0).
What is the best way to do it?
I mean something like this:
Using abline function seems to be the way. Thanks for the help.
Think this should work. Not sure if it's the best way though
plot(x = 0,y = 0,xlab = "X",ylab = "Y", xlim = c(-10,10), ylim = c(-10,10))
c <- c(1:10) #Store the different values of your constant in this vector
for(i in 1:10){
abline(coef = c(0,c[i]))
}
If you want different limits on your X and Y axis change the values of xlim and ylim.

Equally spaced out lengths in dendrograms [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
In this diagram, the main information (most nodes) is on the extreme left side.
I want to make the dendrogram easy to read and thus the edges should be proportionally long. Any specific arguments to be used or is it just the data's problem?
Package ape has an option for plotting a tree (or dendrogram) without edge lengths.
library(ape)
# calculate dendrogram from sample data
data(carnivora)
tr <- hclust(dist(carnivora[1:20,6:15]))
# convert dendrogram from class 'hclust' to 'phylo'
tr <- as.phylo(tr)
# plot, use par(mfrow=c(1,3)) to display side by side
plot(tr)
plot(tr, use.edge.length = FALSE)
plot(tr, use.edge.length = FALSE, node.depth = 2)
This calls the plot.phylo function and enables you to manipulate how the dendrogram looks like. To improve legibility of labels, you might need to tinker settings within plot that influence font size (cex = 0.7) or offset of the label (label.offset = 0.5).

Resources