The ggplot2 graphite line has line sections filled with solid color, why?

I have a question regarding a weird result for a line chart that uses faces. I have water data measurements for various depths (= pressure). The data comes as a table as such:

Pressure Temperature pH
0        30          8.1
1        28          8.0

I “melt” this data to get:

Pressure variable    value
0        Temperature 30
1        Temperature 30
0        pH          8.1
1        pH          8.0

etc. I will do it now:

ggplot(data.m.df, aes(x=value, y=Pressure)) +
  facet_grid(.~variable, scale = "free") +
  scale_y_reverse() +
  geom_line() +
  opts(axis.title.x=theme_blank())

This works, except for those sections of the line that are filled with solid color. I have no idea why, especially because it works great if I swap x for y and use the ~ variable. like the facet_grid formula. weird plot

+5
source share
1 answer

Note the difference between geom_lineand geom_pathapplied to the same data.

library(ggplot2)

x = c(seq(1, 10, 1), seq(10, 1, -1))
y = seq(0, 19, 1)
df = data.frame(x, y)

ggplot(df, aes(x, y)) + geom_line()
ggplot(df, aes(x, y)) + geom_path() 

enter image description here

df.

    x  y
1   1  0
2   2  1
3   3  2
4   4  3
5   5  4
6   6  5
7   7  6
8   8  7
9   9  8
10 10  9
11 10 10
12  9 11
13  8 12
14  7 13
15  6 14
16  5 15
17  4 16
18  3 17
19  2 18
20  1 19

geom_path .

geom_line x.

, x .

x = c(seq(1, 10, .01), seq(10, 1, -.01))
y = seq(.99, 19, .01)
df = data.frame(x, y)

ggplot(df, aes(x, y)) + geom_line() 
ggplot(df, aes(x, y)) + geom_path()

enter image description here

+10

All Articles