ggplot same data, different plots
1
0
Entering edit mode
alptaciroglu ▴ 50
@alptaciroglu-8859
Last seen 4.7 years ago
Turkey

Dear All,

 

I have a dataframe which I want to plot two different variables, x-axis and y-axis respectively. 

A sample from my dataframe looks like this but just imagine this with a lot more columns :

Groups     X -axis    Y -axis

Group1      10            20

Group1      15            25

Group1      20            25

Group2      5             10

Group2      10           15

......

 

When I try to plot all groups using  code below:

c <- ggplot(data=plotMatrix, aes(x= X-axis, y= Y-axis, group = Groups , colour = Groups))

c + stat_smooth(se=FALSE)

 

I get a plot where one of the lines is kind of an outlier. But since I have many groups to be able to tell which group is the outlier (colour code is very similar for large amount of groups), I wanted to divide the dataset. This is where I realized depending on which groups I divide my dataset into, I get a different plot each time. I am not making a mistake in subsetting as number of rows are the same between groups (I double checked using R and excel). It is just some groups (Group1) are represented by two different lines in the plot depending on whether I take Group1 (representation #1) only or Group1, Group2 and Group4 (representation #2 ) together or Group1, Group5 and Group17 together (representation #2 ) or again Group1, Group3 (representation #1 again). Anyone knows anything about this? Thanks for your input

ggplot2 ggplot plot • 1.7k views
ADD COMMENT
1
Entering edit mode
@james-w-macdonald-5106
Last seen 3 days ago
United States

ggplot2 is a CRAN package, so you should be asking for help on r-help@r-project.org.

ADD COMMENT

Login before adding your answer.

Traffic: 582 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6