I have been trying to plot the result of normalmixEM using the method described by jlhoward found here. My problem is that my dataset comes right off the y-axis, leading to a result that looks like this:
I can't figure out how to keep geom_polygon from wrapping like that when it runs into the y-axis.
Thanks for the help!
Related
I produced this dotplot using Seurat, as shown in the picture
but I would to order the plot to show the dots starting from bottom left to top right.
I could do this manually with
my_levels <- c(names, names, names,..........) Idents(obj_name) <- factor(Idents(obj_name), levels= my_levels)
but I would to find a faster way to do it.
thanks
I am guessing this answer is a little late. But If I understood the question correctly you could just order the list of genes differently to obtain the desired outcome.
I want to add an additional tick to my plot in ggplot2, and used Solution 2 as described in the post Annotate ggplot with an extra tick and label.
It worked fine for me, giving the following result in R Studio:
But when I try to save the result using ggsave() to create the a .pdf, .ps, or .png file, the red number is cut off half like this:
I have the feeling that the inner plot is printed first and later the margins are plotted on top of this.
Anybody has a hint?
Thank you Z. Lin! I just had a grid.draw(g) instead of g <- grid.draw(g). This dot in R always activates my python brain region :)
Is there any difference between using breaks=c(1,2,3,4,5) and breaks=c(1:5)?
I am using hist(...) function to get a histogram for a dataset.
If I use hist(MyDataFile$V3, breaks=c(1,2,3,4,5)), then I get the correct histogram.
If I use hist(MyDataFile$V3, breaks=c(1:5)) or
hist(MyDataFile$V3, breaks=seq(1,5,1)), then the histogram does not show correct rectangles, and it only gives me a lot of vertical parallel lines at some breaks instead, but not the correct histogram.
I cannot figure out what is wrong with my the value of my breaks.
[UPDATA] It is a silly mistake. The problem is solved if set freq=FALSE. Thank you all for your time.
I have the following plot:
plot.ts(returns)
I have another dataframe ma_sd which contains the rolling SD from moving averages of the above returns. The df is structured exactly like returns. Is there a simple way to add each line to the corresponding plots?
lines(1:N, ma_sd) seemed intuitive, but it does not work.
Thanks
The only way I can see you doing this is to plot them separately. This code is a bit clunky but will allow you full flexibility to be able to specify labels and axis ranges. You can build on this.
par(mfrow=c(3,1),oma=c(5,4,4,2),mar=c(0,0,0,0))
time<-as.data.frame(matrix(c(1:length(returns[,1])),length(returns[,1]),3))
plot(time[,1],returns[,1],type='l',xaxt='n')
points(time[,1],ma_sd[,1],type='l',col='red')
plot(time[,2],returns[,2],type='l',xaxt='n')
points(time[,2],ma_sd[,2],type='l',col='red')
plot(time[,3],returns[,3],type='l')
points(time[,3],ma_sd[,3],type='l',col='red')
I have a VERY basic plot in R, and I'd like to solve two issues. Here is the code which produces the plot:
plot(o,n,bty="n",pch=21,cex=1.5,bg="gray",xlab="y",ylab="x",lwd=2)
And, here's the plot
There are two unwanted behaviors of this plot that I'm trying to fix. And I don't know how to do either one (nor do I understand why R doesn't do these things already...)
The X and Y axes do not meet. There is a gap near the origin in this plot. I want to remove that. The axes should touch, just like any other graph.
The data extends past the axis is both the X and Y direction. This clearly is unwanted. How can I fix this without having to manually make my own axis. Seems like there should be something more intuitive here.
bty="l".
You may also want to use something like:
xlim=c(0.02, 0.24), ylim=c(0.02, 0.24)
if you don't like the default limits of your two axes.
In general, check out ?par for guidance on both of these and many other options.
Try leaving out bty="n" or replacing it by bty="L" if you really do not want a box with edges above or on the right