python - Which languages allow importing non-rectangular data to plot -
i have deal data multiple experimental runs have different x-axis sizes. data may instance.
[1 2 3 4] [5 6] [7 8 9 10 15] [4]
this means languages (e.g. matlab) either have tough time reading in data, or aren't plotting friendly (e.g. java). can suggest language makes importing, manipulating, , plotting data easy? switched python numpy/scipy haven't found helpful (i using python). please post specific functionality opposed blanket statements language. thanks
here's attempt in free, open-source statistical programming language r - i'll try update more specifics data.
as example data file, i'm using .txt these lines:
1, 2, 3, 4 5, 6 7, 8, 9, 10, 15 4
to read in data, i'd write:
# set option - trust me options(stringsasfactors = false) # read each line of file vector of strings x <- readlines(con = file("blah.txt")) # split whatever delimiter xlist <-strsplit(x, ", ") # now, each experiment's data element in xlist # it'll easiest plot if whole thing data.frame # i'm there's more elegant way this, but... # name elements of xlist (kludge) names(xlist) <- c("experiment 1", "experiment 2", "experiment 3", "experiment 4") # convert each experiment's data data.frame, stack # using package plyr library(plyr) dat <- ldply(names(xlist), .fun = function(expname) { data.frame(exp = expname, result = xlist[[expname]]) }) # check out data.frame make sure came through okay str(dat) # might need convert string numeric... dat$result <- as.numeric(dat$result) # plot (for i'd use ggplot2) library(ggplot2) # results ggplot(dat, aes(x = result)) + geom_histogram() # experiment ggplot(dat, aes(x = result)) + geom_histogram() + facet_wrap( ~ expname) # overlaid densities - doesn't work if experiment has few results ggplot(dat, aes(x = result, color = expname)) + geom_density()
no doubt there's more elegant way this, general flow in r - read in list (doesn't need rectangular data), convert molten-format data (inherently rectangular), plot.
Comments
Post a Comment