Related
I have this dataframe:
structure(list(taxon = c("Acidaminococcus", "Butyricicoccus",
"Butyrivibrio", "Collinsella", "Coprococcus", "Olsenella", "Parabacteroides",
"Paraprevotella", "Pasteurellaceae_unclassified"), lfc_StatusChronic.ACST0. = c(0.88175957,
0.88803574, 0.790947444, 1.319321361, 0.7176503, 0.758374253,
-0.833877215, -1.106098414, 0.932218695), se_StatusChronic.ACST0. = c(0.439259504,
0.449835605, 0.369268494, 0.391714918, 0.27578621, 0.364036816,
0.377314959, 0.485078744, 0.421283473), lfc_Time.fT1 = c(-0.021243562,
0.66196107, 0.334274258, -0.382520121, -0.005363874, -0.313304181,
-0.439558941, -0.029316428, 0.682658747), se_Time.fT1 = c(0.312681188,
0.330173331, 0.301559494, 0.309355933, 0.293938402, 0.302957725,
0.339292487, 0.361459254, 0.385696553), lfc_Time.fT2 = c(-1.092105655,
-0.083635974, -0.435405323, -1.221704783, -0.557850053, -0.734425087,
-0.19277856, 0.148094198, 0.461233277), se_Time.fT2 = c(0.326565043,
0.344533883, 0.31544836, 0.323423323, 0.307225241, 0.317023725,
0.354270528, 0.377368442, 0.403530764), lfc_Time.fT3 = c(-0.684898535,
0.007779894, -0.661494348, -0.765693993, -0.294827229, -1.082174069,
-0.428338824, 0.072377208, 0.682615791), se_Time.fT3 = c(0.324919486,
0.342422134, 0.314578177, 0.322254678, 0.305999846, 0.316331693,
0.352370636, 0.375283079, 0.402530027), lfc_Time.fT4 = c(-1.038613852,
-0.159777157, -0.172345815, -0.691220321, -0.444048742, -1.062300665,
0.073495083, 0.295212326, 0.337145234), se_Time.fT4 = c(0.319416657,
0.336513636, 0.309526757, 0.316959694, 0.300928605, 0.311343927,
0.346365478, 0.36886735, 0.396117478), lfc_Time.fT5 = c(-0.714954683,
0.081376697, -0.621676699, -0.483698623, -0.339094441, -0.718106519,
-0.055315775, 0.475970869, 0.160939365), se_Time.fT5 = c(0.317230276,
0.334106044, 0.307553106, 0.314893819, 0.298943665, 0.309379791,
0.343965965, 0.366296439, 0.393607858)), row.names = c(NA, -9L
), class = "data.frame")
It is a dataframe where each row is a category, and the columns correspond with a time series (from T0 til T5).
I want to do a bar chart for each category (taxon) for their time (T0-T5):
melted_df <- reshape2::melt(taxonFC1, id.vars = "taxon", variable.name = "timepoint", value.name = "value")
ggplot(melted_df, aes(x = timepoint, y = value, fill = taxon)) +
geom_bar(stat = "identity") +
facet_wrap(~ taxon, ncol = 3) +
labs(title = "Bar Chart for Different Time Series",
x = "Time Point",
y = "Value",
fill = "Category")
The question is if it is possible to assign the standard error (se columns) to their logFC value (lfc columns) for each time series.
Update:
I did this, but only for T0:
ggplot(data = taxonFC1, aes(x = taxon, y = lfc_StatusChronic.ACST0., fill = taxon)) +
geom_bar(stat = "identity") +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
xlab("Category") +
ylab("lfc_StatusChronic.ACST0.") +
ggtitle("Bar Plot of lfc_StatusChronic.ACST0. by Category") +
# Add error bars using se_StatusChronic.ACST0. column
geom_errorbar(aes(ymin = lfc_StatusChronic.ACST0. - se_StatusChronic.ACST0.,
ymax = lfc_StatusChronic.ACST0. + se_StatusChronic.ACST0.),
width = 0.4)
Output expected (the image is from other data):
Is this what you're looking for?
library(dplyr)
library(tidyr)
library(ggplot2)
dat <- structure(list(taxon = c("Acidaminococcus", "Butyricicoccus",
"Butyrivibrio", "Collinsella", "Coprococcus", "Olsenella", "Parabacteroides",
"Paraprevotella", "Pasteurellaceae_unclassified"), lfc_StatusChronic.ACST0. = c(0.88175957,
0.88803574, 0.790947444, 1.319321361, 0.7176503, 0.758374253,
-0.833877215, -1.106098414, 0.932218695), se_StatusChronic.ACST0. = c(0.439259504,
0.449835605, 0.369268494, 0.391714918, 0.27578621, 0.364036816,
0.377314959, 0.485078744, 0.421283473), lfc_Time.fT1 = c(-0.021243562,
0.66196107, 0.334274258, -0.382520121, -0.005363874, -0.313304181,
-0.439558941, -0.029316428, 0.682658747), se_Time.fT1 = c(0.312681188,
0.330173331, 0.301559494, 0.309355933, 0.293938402, 0.302957725,
0.339292487, 0.361459254, 0.385696553), lfc_Time.fT2 = c(-1.092105655,
-0.083635974, -0.435405323, -1.221704783, -0.557850053, -0.734425087,
-0.19277856, 0.148094198, 0.461233277), se_Time.fT2 = c(0.326565043,
0.344533883, 0.31544836, 0.323423323, 0.307225241, 0.317023725,
0.354270528, 0.377368442, 0.403530764), lfc_Time.fT3 = c(-0.684898535,
0.007779894, -0.661494348, -0.765693993, -0.294827229, -1.082174069,
-0.428338824, 0.072377208, 0.682615791), se_Time.fT3 = c(0.324919486,
0.342422134, 0.314578177, 0.322254678, 0.305999846, 0.316331693,
0.352370636, 0.375283079, 0.402530027), lfc_Time.fT4 = c(-1.038613852,
-0.159777157, -0.172345815, -0.691220321, -0.444048742, -1.062300665,
0.073495083, 0.295212326, 0.337145234), se_Time.fT4 = c(0.319416657,
0.336513636, 0.309526757, 0.316959694, 0.300928605, 0.311343927,
0.346365478, 0.36886735, 0.396117478), lfc_Time.fT5 = c(-0.714954683,
0.081376697, -0.621676699, -0.483698623, -0.339094441, -0.718106519,
-0.055315775, 0.475970869, 0.160939365), se_Time.fT5 = c(0.317230276,
0.334106044, 0.307553106, 0.314893819, 0.298943665, 0.309379791,
0.343965965, 0.366296439, 0.393607858)), row.names = c(NA, -9L
), class = "data.frame")
dat %>%
rename(lfc_time.fT0 = lfc_StatusChronic.ACST0.,
se_Time.fT0 = se_StatusChronic.ACST0.) %>%
pivot_longer(-taxon, names_pattern="(.*)_[Tt]ime\\.f(.*)",
names_to = c(".value", "time")) %>%
ggplot(aes(x = time, y = lfc, ymin = lfc - se, ymax = lfc + se, fill = taxon)) +
geom_bar(stat = "identity") +
geom_errorbar(width=.4) +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
scale_fill_brewer(palette="Set1") +
xlab("Category") +
ylab("lfc_StatusChronic.ACST0.") +
facet_wrap(~taxon, ncol=1) +
ggtitle("Bar Plot of lfc_StatusChronic.ACST0. by Category")```
If so, the key is to rename the T0 variables to have the same format as the other time-period variables and then use pivot_longer() to put all the lfc measures in a single column and all the se measures in a single column. The rest is accomplished with faceting on the time variable. The pivot_longer() documentation has some good examples of retaining multiple columns, see in particular the last example on the page.
Given this R script:
library(glue)
library(ggplot2)
ir.data <- read.csv(file="~/apps/mine/cajueiro_weather_station/sensor_data/temperature_data.csv", header = F)
ir.data$V1 <- as.POSIXct(ir.data$V1, format = "%Y-%m-%dT%H:%M:%S", tz = "UTC")
ir.data$size <- (ir.data$V2 - ir.data$V3)
ggplot(ir.data, aes(x=V1)) +
labs(title = "IR-radiation-based sky temperature monitoring.",
subtitle = glue("Samples from {ir.data$V1[1]}h to {tail(ir.data$V1, n=1)}h UTC-3."),
caption = "Cajueiro Weather Station - fschuindt.githhub.io/blog/weather") +
geom_line(aes(y = V2), color = "#6163c2") +
geom_line(aes(y = V3), color = "#ad1fa2") +
scale_color_discrete(name = "Labels", labels = c("Ambient temperature.", "Sky temperature.")) +
xlab("Timestamp") +
ylab("Measured temperature in °Celcius")
And this .csv data sample:
2022-04-30T19:47:00,28.03,28.05
2022-04-30T19:47:02,27.99,28.01
2022-04-30T19:47:04,28.07,28.01
2022-04-30T19:47:06,28.05,28.05
2022-04-30T19:47:08,28.05,28.01
2022-04-30T19:47:10,28.03,28.01
2022-04-30T19:47:12,28.05,27.99
2022-04-30T19:47:14,28.07,28.01
2022-04-30T19:47:16,28.07,28.05
2022-04-30T19:47:18,28.05,28.05
2022-04-30T19:47:20,28.09,28.07
That's the plot output (the .csv data is bigger than the example):
Why the labels described at scale_color_discrete(name = "Labels", labels = c("Ambient temperature.", "Sky temperature.")) are not being displayed?
It's not recognising those values in an aes call to colour. Reshape data to put all y values in a single column, pass a grouping variable to aes(colour = ...) and use scale_colour_manual to set colours instead:
library(tidyverse)
ir.data <- read_csv(
"2022-04-30T19:47:00,28.03,28.05
2022-04-30T19:47:02,27.99,28.01
2022-04-30T19:47:04,28.07,28.01
2022-04-30T19:47:06,28.05,28.05
2022-04-30T19:47:08,28.05,28.01
2022-04-30T19:47:10,28.03,28.01
2022-04-30T19:47:12,28.05,27.99
2022-04-30T19:47:14,28.07,28.01
2022-04-30T19:47:16,28.07,28.05
2022-04-30T19:47:18,28.05,28.05
2022-04-30T19:47:20,28.09,28.07",
col_names = c("V1", "V2", "V3")
)
ir.data %>%
pivot_longer(-V1, names_to = "Labels", values_to = "V") %>%
ggplot(aes(x = V1, y = V, colour = Labels)) +
labs(
title = "IR-radiation-based sky temperature monitoring.",
subtitle = glue::glue(
"Samples from {ir.data$V1[1]}h to {tail(ir.data$V1, n=1)}h UTC-3."
),
caption = "Cajueiro Weather Station - fschuindt.githhub.io/blog/weather"
) +
geom_line(size = 1) +
scale_color_manual(
name = "Labels",
,
values = c("#6163c2", "#ad1fa2"),
limits = c("V2", "V3"),
labels = c("Ambient temperature.", "Sky temperature."),
) +
xlab("Timestamp") +
ylab("Measured temperature in °Celcius")
Created on 2022-05-06 by the reprex package (v2.0.1)
I struggle to add a line on top with the total of this stacked barchart:
demandDriversdf = structure(list(year = structure(c(1356998400, 1388534400, 1420070400,
1451606400, 1483228800), tzone = "GMT", tclass = c("POSIXct",
"POSIXt"), class = c("POSIXct", "POSIXt")), one= c(12.4882571461364,
13.0984912135388, 12.1908055157534, 8.35335266490711, 4.38593754938248
), two= c(8.73113484771066, -4.34931681021004, -3.04955505552055,
-1.69136803847247, 3.06500464975644), three= c(0.0669199673877559,
-0.194488564805058, 0.721483847234409, 2.85829802643513, 6.14894193920574
), four= c(6.98748008979101, 3.7122726468811, -15.0029846301367,
-20.3768539034347, 9.38948700033012)), .Names = c("year", "one",
"two", "three", "four"), row.names = c("2013-01-01", "2014-01-01",
"2015-01-01", "2016-01-01", "2017-01-01"), class = "data.frame")
demandDriversdf2 = reshape2::melt(demandDriversdf, id.vars=c("year"), value.name="driver")
rowS = rowSums(demandDriversdf[,setdiff(colnames(demandDriversdf),"year")])
demandDriversdf2 = rbind(demandDriversdf2, data.frame(year = names(rowS), variable="Total", driver = rowS))
demandDriversdf2$year=substr(demandDriversdf2$year,1,4)
demandDriversdf2_1 <- subset(demandDriversdf2,driver >= 0 & variable!="Total")
demandDriversdf2_2 <- subset(demandDriversdf2,driver < 0 & variable!="Total")
gdemandDrivers = ggplot2::ggplot() +
ggplot2::geom_bar(data = demandDriversdf2_1, aes(x=year, y=driver, fill=variable),stat = "identity") +
ggplot2::geom_bar(data = demandDriversdf2_2, aes(x=year, y=driver, fill=variable),stat = "identity") +
ggplot2::geom_line(data = subset(demandDriversdf2, variable=="Total"), aes(x=year, y=driver)) +
ggplot2::scale_fill_brewer(palette = 2, type = "qual")
I get this strange warning
geom_path: Each group consists of only one observation. Do you need to
adjust the group aesthetic?
and ideally would like the line to be in black with also black points.
Just add group = 1 to aes() in geom_line():
library(ggplot2)
ggplot() +
geom_bar(data = demandDriversdf2_1, aes(x=year, y=driver, fill=variable),stat = "identity") +
geom_bar(data = demandDriversdf2_2, aes(x=year, y=driver, fill=variable),stat = "identity") +
geom_line(data = subset(demandDriversdf2, variable=="Total"),
aes(x=year, y=driver, group = 1)) +
scale_fill_brewer(palette = 2, type = "qual")
The reason for this:
For line graphs, the data points must be grouped so that it knows which points to connect. In this case, it is simple -- all points should be connected, so group=1. When more variables are used and multiple lines are drawn, the grouping for lines is usually done by variable.
Reference: Cookbook for R, Chapter: Graphs Bar_and_line_graphs_(ggplot2), Line graphs.
I want to plot intervals of confidence of fitted values. I read some post related, but I am still stuck..These are a sample of the date:
pd <-structure(list(date = 1:5, obs = c(44.6651011845397, 62.3441339250369,
52.8968240161506, 51.7795930633478, 63.1284636561025), pred = c(47.2643891039645,
55.7996450577325, 52.9566469533233, 51.3393289316, 59.0011440099732)),
.Names = c("date", "obs", "pred"), row.names = c(NA, 5L), class = "data.frame")
pd2 <- structure(list(date = 1:5, lwr = c(44.8529592578518, 54.9926370476338,
51.7358955911624, 49.401869166722, 58.1674619447108), upr = c(49.6758189500772,
56.6066530678312, 54.1773983154842, 53.2767886964779, 59.8348260752356
)), .Names = c("date", "lwr", "upr"), row.names = c(NA, 5L), class = "data.frame")
dd <- melt(pd, id=c("date")) #Data
dd2 <- melt(pd2,id=c("date")) #Intervals of conf.
p <- ggplot(dd) + geom_line(aes(x=date, y=value, colour=variable))
p <- p + geom_smooth(aes(x=date, y=value, ymax=lwr, ymin=upr), #1 way
colour='grey', data=dd2, stat='identity')
Also tried...
# p+ geom_ribbon(data=dd2,aes(ymin=lwr,ymax=upr),alpha=0.3) #2.
I received the error:
Error in eval(expr, envir, enclos) : object 'lwr' not found ....what am I missing?
I also tried to do it without using melt ... but then I also had problems with the legend!
In the first way, the dd object you are using is not having the lwr/upr columns. So you cannot really plot them.
Can you do a:
dd<-merge(dd,pd2,by='date')
just after the melts and then:
p <- ggplot(dd) + geom_line(aes(x=date, y=value, colour=variable))
p + geom_ribbon(data=dd,aes(x=date, y=value, ymin=lwr,ymax=upr, group=variable),alpha=0.3)
Is this helping?
I would like to plot the following dataset
structure(list(X = structure(c(3L, 12L, 11L, 7L, 13L, 2L, 1L,
10L, 5L, 4L, 8L, 14L, 9L, 6L), .Label = c("BUM", "DDR", "ETB",
"EXP", "HED", "HEDOS", "KON", "LEIT", "MAIN", "MAT", "PER", "PMA",
"TRA", "TRADITION"), class = "factor"), Geschaeft = c(0.0468431771894094,
0.0916666666666667, 0.0654761904761905, 0.0905432595573441, 0.0761904761904762,
0.0672097759674134, 0.0869565217391304, 0.0650887573964497, 0.0762250453720508,
0.0518234165067179, 0.0561330561330561, 0.060077519379845, 0.0865384615384615,
0.0628683693516699), Gaststaette = c(0.0855397148676171, 0.0604166666666667,
0.0555555555555556, 0.0764587525150905, 0.0895238095238095, 0.0712830957230143,
0.075098814229249, 0.0631163708086785, 0.0780399274047187, 0.0383877159309021,
0.0561330561330561, 0.0581395348837209, 0.0596153846153846, 0.0648330058939096
), Bank = c(0.065173116089613, 0.0854166666666667, 0.0972222222222222,
0.0824949698189135, 0.060952380952381, 0.0529531568228106, 0.0731225296442688,
0.0828402366863905, 0.0725952813067151, 0.0806142034548944, 0.0686070686070686,
0.0503875968992248, 0.0807692307692308, 0.0550098231827112),
Hausarzt = c(0.0712830957230143, 0.0833333333333333, 0.0912698412698413,
0.0704225352112676, 0.0628571428571429, 0.0672097759674134,
0.106719367588933, 0.0710059171597633, 0.108892921960073,
0.0940499040307102, 0.0852390852390852, 0.0794573643410853,
0.0826923076923077, 0.110019646365422), Einr..F..Aeltere = c(0.10183299389002,
0.104166666666667, 0.107142857142857, 0.100603621730382,
0.12, 0.116089613034623, 0.112648221343874, 0.112426035502959,
0.121597096188748, 0.0998080614203455, 0.118503118503119,
0.131782945736434, 0.121153846153846, 0.104125736738703),
Park = c(0.0855397148676171, 0.0666666666666667, 0.0912698412698413,
0.0804828973843058, 0.0704761904761905, 0.0672097759674134,
0.0731225296442688, 0.0670611439842209, 0.0834845735027223,
0.0806142034548944, 0.0686070686070686, 0.0658914728682171,
0.0884615384615385, 0.0609037328094303), Sportstaette = c(0.0855397148676171,
0.0791666666666667, 0.0952380952380952, 0.0824949698189135,
0.0933333333333333, 0.114052953156823, 0.0810276679841897,
0.0788954635108481, 0.0780399274047187, 0.0825335892514395,
0.0831600831600832, 0.0852713178294574, 0.0884615384615385,
0.1237721021611), OEPNV = c(0.0529531568228106, 0.05625,
0.0456349206349206, 0.0583501006036217, 0.0666666666666667,
0.0366598778004073, 0.0434782608695652, 0.0571992110453649,
0.0344827586206897, 0.0633397312859885, 0.0478170478170478,
0.062015503875969, 0.0519230769230769, 0.0235756385068762
), Mangel.an.Gruenflaechen = c(0.0692464358452139, 0.0645833333333333,
0.0694444444444444, 0.0422535211267606, 0.0666666666666667,
0.0692464358452139, 0.0711462450592885, 0.0749506903353057,
0.0598911070780399, 0.0959692898272553, 0.0623700623700624,
0.0717054263565891, 0.0653846153846154, 0.0746561886051081
), Kriminalitaet = c(0.0672097759674134, 0.0541666666666667,
0.0476190476190476, 0.0422535211267606, 0.0628571428571429,
0.0509164969450102, 0.0454545454545455, 0.0532544378698225,
0.058076225045372, 0.072936660268714, 0.0602910602910603,
0.063953488372093, 0.0461538461538462, 0.0648330058939096
), Auslaender = c(0.0244399185336049, 0.04375, 0.0416666666666667,
0.0663983903420523, 0.0228571428571429, 0.0509164969450102,
0.0237154150197628, 0.0236686390532544, 0.0217785843920145,
0.0441458733205374, 0.024948024948025, 0.0232558139534884,
0.0230769230769231, 0.0451866404715128), Umweltbelastung = c(0.0468431771894094,
0.0479166666666667, 0.0476190476190476, 0.0402414486921529,
0.0438095238095238, 0.0468431771894094, 0.0454545454545455,
0.0512820512820513, 0.0417422867513612, 0.0518234165067179,
0.0478170478170478, 0.0445736434108527, 0.0442307692307692,
0.0451866404715128), Einr..f..Kinder = c(0.0753564154786151,
0.075, 0.0555555555555556, 0.0724346076458753, 0.0533333333333333,
0.0794297352342159, 0.075098814229249, 0.0788954635108481,
0.0598911070780399, 0.0460652591170825, 0.0977130977130977,
0.0930232558139535, 0.0634615384615385, 0.0451866404715128
), Einr..f..Jugendliche = c(0.122199592668024, 0.0875, 0.0892857142857143,
0.0945674044265594, 0.11047619047619, 0.109979633401222,
0.0869565217391304, 0.120315581854043, 0.105263157894737,
0.0978886756238004, 0.122661122661123, 0.11046511627907,
0.0980769230769231, 0.119842829076621)), .Names = c("X",
"Geschaeft", "Gaststaette", "Bank", "Hausarzt", "Einr..F..Aeltere",
"Park", "Sportstaette", "OEPNV", "Mangel.an.Gruenflaechen", "Kriminalitaet",
"Auslaender", "Umweltbelastung", "Einr..f..Kinder", "Einr..f..Jugendliche"
), row.names = c(NA, -14L), class = "data.frame")
So that it look like this picture (or better with each line in a seperate plot) that I created with Excel.
But I can't figure out how...
Thanks a lot for your help.
Dominik
UPDATE: Here is just a map of what the groups (BUM,DDR,ETB etc.) mean.
This is an extension to #Andrie's solution. It combines the faceting idea with that of overplotting (stolen liberally from the learnr blog, which I find results in a cool visualization. Here is the code and the resulting output. Comments are welcome
mdf <- melt(df, id.vars="X")
mdf = transform(mdf, variable = reorder(variable, value, mean), Y = X)
ggplot(mdf, aes(x = variable, y = value)) +
geom_line(data = transform(mdf, X = NULL), aes(group = Y), colour = "grey80") +
geom_line(aes(group = X)) +
facet_wrap(~X) +
opts(axis.text.x = theme_text(angle=90, hjust=1))
EDIT: If you have groupings of milieus, then a better way to present might be the following
mycols = c(brewer.pal(4, 'Oranges'), brewer.pal(4, 'Greens'),
brewer.pal(3, 'Blues'), brewer.pal(3, 'PuRd'))
mdf2 = read.table(textConnection("
V1, V2
ETB, LEIT
PMA, LEIT
PER, LEIT
LEIT, LEIT
KON, TRADITION
TRA, TRADITION
DDR, TRADITION
TRADITION, TRADITION
BUM, MAIN
MAT, MAIN
MAIN, MAIN
EXP, HEDOS
HED, HEDOS
HEDOS, HEDOS"), sep = ",", header = T, stringsAsFactors = F)
mdf2 = data.frame(mdf2, mycols = mycols)
mdf3 = merge(mdf, mdf2, by.x = 'X', by.y = "V1")
p1 = ggplot(mdf3, aes(x = variable, y = value, group = X, colour = mycols)) +
geom_line(subset = .(nchar(as.character(X)) == 3)) +
geom_line(subset = .(nchar(as.character(X)) != 3), size = 1.5) +
facet_wrap(~ V2) +
scale_color_identity(name = 'Milieus', breaks = mdf2$mycols, labels = mdf2$V1) +
theme_bw() +
opts(axis.text.x = theme_text(angle=90, hjust=1))
The trick is to reshape your data into tall format before you pass it to ggplot. This is easy when using the melt function in package reshape2:
Assuming your data is a variable called df:
library(reshape2)
library(ggplot2)
mdf <- melt(df, id.vars="X")
str(mdf)
ggplot(mdf, aes(x=variable, y=value, colour=X, group=X)) + geom_line() +
opts(axis.text.x = theme_text(angle=90, hjust=1))
Edit As #Chase suggests, you can use facetting to make the plot more readable:
ggplot(mdf, aes(x=X, y=value)) + geom_point() +
opts(axis.text.x = theme_text(angle=90, hjust=1)) + facet_wrap(~variable)
First, melt the data to put it in a long format.
melted_data <- melt(the_data, id.vars = "X")
Now draw the plot with a numeric x axis, and fix up the labels.
p <- ggplot(melted_data, aes(as.numeric(variable), value, colour = X)) +
geom_line() +
scale_x_continuous(
breaks = seq_len(nlevels(melted_data$variable)),
labels = levels(melted_data$variable)
) +
opts(axis.text.x = theme_text(angle = 90))
p
Having answered this, I'm not sure what the plot tells you &ndahs; it's just a jumble of lines to me. You might be better greying out most of the lines, and highlighting one or two interesting ones.
Add a column that picks out, e.g., EXP.
melted_data$is_EXP <- with(melted_data, X == "EXP")
Ignore my previous anser; Andrie's is better. Use manual colour and size scales to highlight your new column.
p <- ggplot(melted_data, aes(variable, value, colour = is_EXP, size = is_EXP, group = X)) +
geom_line() +
scale_colour_manual(values = c("grey80", "black")) +
scale_size_manual(values = c(0.5, 1.5)) +
opts(axis.text.x = theme_text(angle = 90, hjust=1))
p