bill999
bill999

Reputation: 2550

How to better display this plot in ggplot2

I am using ggplot2 to produce the attached file.enter image description here

My question is how can I use R+ggplot2 in order to make this plot less busy and easier to see what is going on in the data? There are about 1000 observations and each observation has between 1 and 15 data points. I connect the observations with >1 datapoint with lines.

Is there maybe something to be done with the color scheme? Or possibly grouping things together?

My code looks something like this:

ggplot(data, aes(variable, value, group=Name, color=Name))+
geom_point(alpha=.2, size=5)+
geom_line()+
geom_text(aes(label=Name),hjust=0, vjust=0, size=2)

Upvotes: 0

Views: 270

Answers (1)

MichaelVE
MichaelVE

Reputation: 1344

Before any advice can be given you need to determine what data you want to group together. Perhaps you can group your data by gender/age. This can be done by changing 'color = Name' into 'color = Gender' if that column exists in your data.

The color scheme can be changed with scale_brewer. However, in every palette there are limited colors available so it will not be possible to have a distinct different color for each individual. http://docs.ggplot2.org/current/scale_brewer.html

If you want, your legend can also be changed in multiple columns with

+ guides(fill=guide_legend(ncol=2))

You can also change your theme options with

axis.text.x = element_text(angle = -330)

To turn your x-axis which will make it readable.

Upvotes: 1

Related Questions