Adam_G
Adam_G

Reputation: 7879

Increase Maximum Width of Line in Line Plot

I am using qplot in the ggplot2 library to create a line graph. I am attempting to vary both the color and width of the line. The problem, though, is that the width of the line seems to be constrained, regardless of the values I give to the parameter. In the qplot function, I've also tried using "size" in place of "lwd", but this does not make a difference.

As an example, these values result in the first plot:

line.x <- c(1,2,3,4,5)
line.y <- c(1,2,3,4,5) 
line.width <- c(1,2,3,4,5) 
line.color <- c(1,2,3,4,5)
qplot(line.x, line.y, geom = 'line', lwd = line.width, colour = line.color) + 
  scale_color_gradientn(colours=rainbow(50)) + 
  theme(legend.position="none")

enter image description here

If I change the 4th value in line.width to 40, it just makes the other parts relatively thinner:

line.width <- c(1,2,3,40,5)

enter image description here

Increasing again to 400 has a similar effect, where the 4th segment can only be expanded to a maximum width:

line.width <- c(1,2,3,400,5)

enter image description here

As a note, my actual data set will have hundreds of values, and look more similar to this: enter image description here

Is there a way to increase the maximum thickness of the line?

Upvotes: 3

Views: 1189

Answers (2)

user514348
user514348

Reputation: 51

How can i do the same in kml as i am facing same width increase issue in style tags in kml as given below

<Style id="polystyle2">
 <LineStyle>
<width>500</width>
<color>ff00ffff</color>
</LineStyle>
<IconStyle>
<Icon></Icon>
 </IconStyle>
<LabelStyle>
<color>ff0000ff</color>
</LabelStyle>
</Style>
<Style id="polystyle3">
 <LineStyle>
<width>400</width>
<color>ff00FC7C</color>
</LineStyle>
<IconStyle>
<Icon></Icon>
 </IconStyle>
<LabelStyle>
<color>ff0000ff</color>
</LabelStyle>
</Style>

Upvotes: -1

David Heckmann
David Heckmann

Reputation: 2939

you can use scale_size():

qplot(line.x, line.y, geom = 'line', lwd = line.width, colour = line.color  ) + 
  scale_size(range = c(1, 20)) +
  scale_color_gradientn(colours=rainbow(50)) + 
  theme(legend.position="none")

enter image description here

Upvotes: 5

Related Questions