Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I have a a dataset such as follows:
CON <- data_frame(norm.d.2=c(1.37,1.11,1.84),CDSex.=c(0.439,0.335,0.432))
I am plotting this data frame with ggplot2, but I am unable to change the x axis labels. I have tried both scale_x_continuous and scale_x_discrete, but either I receive an error or no labels at all.
ggplot(CONrc,aes(x=norm.d.2,y=CDSex.)) +
geom_point(aes(color=factor(interaction(hpi,rep)))) +
xlab('Exonic % of Cellular Reads') +
ylab('CDS % of Exonic Reads')
When I try scale_x_continuous(breaks=c(0.5,1.5,2.5)), I get the following error:
Error: Discrete value supplied to continuous scale
When I try scale_x_discrete(breaks=c(0.5,1.5,2.5)), I do not get an error message, but my plot loses all x axis labels.
looks fine for CON table.
try to mutate CONrc
CONrc$norm.d.2 <- as.double(CONrc$norm.d.2)
and then plot this
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am trying to plot a box-plot with ggplot2 using the Wage database in the ISLR package. The box-plot is meant to visualize the Wage versus educational level, which is presented in five categories. When I try to use the typical code to generated the box-plot a get the following warning from Rstudio:
Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.
Error: Aesthetics must be either length 1 or the same as the data (3000): y
My code is
library("ISLR")
library("MASS")
setwd("C:/Users/Alonso/Desktop/ITSL")
View(Wage)
ggplot(Wage, aes(x=education, y=Wage))+
geom_boxplot(outlier.colour="red", outlier.shape=8, outlier.size=4)+labs(x="Nivel de estudio", y="Salario")
I have made other graphics but just with numeric variables, maybe the problem is that now I am using a categorical variable. Any ideas?, thanks in advance and greetings from Chile.
You were almost there, just needed a lowercase y=wage because the column name is wage and not Wage.
ggplot(Wage, aes(x=education, y=wage))+
+ geom_boxplot(outlier.colour="red", outlier.shape=8, outlier.size=4)+labs(x="Nivel de estudio", y="Salario")
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 simulate some data with R code and want to plot these data.
scatter plot is no problem with code plot(SX,Quant),
but when I use plot(SX,Quant,type='l'), the result is
I just want the line through every point.
I try different type of plot, also use ggplot2 to try to modification,
but has same result, plz help me to solve this problem.
Sort your data by the x-value of your plot:
F_inverse=function(x) log((exp(1)-1)*x+1)
U = runif(100)
SX = F_inverse(U)
Quant=rank(SX)/100
ord <- order(SX)
SX <- SX[ord]
Quant <- Quant[ord]
plot(SX,Quant, type="l")
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
In running a knitr report I noticed that ggplot2 produces a graph without y-ticks/labels on Windows, but does on my Linux/Rstudio install.
The following codes shows the issue for me.
df=data.frame(pos=seq(1,10),data=seq(10,1,-1))
ggplot(data=df, aes(x=pos,y=data))+
scale_y_discrete(breaks=seq(1,10,2))+
geom_line()
Here are the graphs that I get:
Windows
Linux
The breaks show if I remove the scale_y_discrete function call, however I need it for formatting my output.
Is this an environmental issue? A configuration issue?
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm trying to make some plots of distributions in R and i have the code but it just won't run, it says there's an unexpected symbol.
curve(dexp(x, rate=3) xlim=c(0,40), main="exp(rate=3) population
distribution", xlab="X", ylab="f(x)")
Im trying to plot an exponential random variable with rate 3.
You are missing a comma between dexp(x, rate=3) and xlim=c(0,40)
curve(dexp(x, rate=3), xlim=c(0,40), main="exp(rate=3) population
distribution", xlab="X", ylab="f(x)")
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have the following dataset:
Time Served MAC BLER
07:16:18.341 7561.60 6721.60 8.33
07:16:18.641 10321.44 8198.24 16.47
I have omitted the other samples for brevity.
I would like to plot in the x-axis Time, and the Y axis the three other variables i.e. Served, MAC and BLER on the same graph in ggplot2.
How can I do this?
many thanks
you need data in melted form.
require(reshape2)
df.m<-melt(df,id.var="Time")
then
ggplot(df.m, aes(x=Time, y=value, color=variable))+geom_line()
but I am afraid about the scaling of y axis