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
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 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
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 does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a matrix
B = matrix(c(1,2,4,1,4,2,1,3.5,4.2,2,2.2,6.5,3,1.2,7.7,1,2.1,1.6,3,5.2,8.2),
nrow = 7)
with 3 columns: the color column (colors from 1-5, representing blue,red,green,yellow,black), the x column and the y column.
I want to plot every points (x,y) with the color from the color column.
First question: what software is best to do so?
Second question: how can I do it with R?
Simple question finds simple answer:
plot(B[,2], B[,3], col=c("blue","red","green","yellow","black")[B[,1]])
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
How to Calculate Circumference [Perimeter] of a Pipe [Cylinder shape] with Specified Pitch?
Actually I want to find the length of thread to wind a pipe.
Is there any formula or formula name I can refer?
What you are looking for is the perimeter of an ellipse which is rather an ugly thing (see: http://www.mathsisfun.com/geometry/ellipse-perimeter.html). Your minor axis is the diameter of the pipe. The major axis is the hypotenuse of the right triangle formed from 1/2 of your pitch.