Implementation of parallel coordinates? [closed]

徘徊边缘 提交于 2019-11-27 19:51:47
VitoshKa

R solution

lattice package comes with R and includes parallel function:

 parallel(~iris[1:4] | Species, iris) 

ggplot2 is also your friend here:

D <- data.frame(Gain = rnorm(20),  
                Trader = factor(LETTERS[1:4]), 
                Day = factor(rep(1:5, each = 4)))
ggplot(D) + 
  geom_line(aes(x = Trader, y = Gain, group = Day, color = Day))

lattice and ggplot require input data in different "shapes". For lattice it's a matrix form, each column is a variable represented on one parallel coordinate. For ggplot it's one column (Gains) and a separate indicator for the variable (Trader above). /this is the reason I used two different examples, not to mess with data reshaping here/.

If you need something quick, then lattice is probably for you. Ggplot requires some time investment.

GGobi has had for aeons (as its predecessor XGobi already had it).

You can access this via the rggobi package from R. And being open source, you get to look under the hood too.

If you are looking to use parallel coordinates, MATLAB has an implementation in the Statistics Toolbox: PARALLELCOORDS.

Otherwise if you want to implement one yourself, the basic version (without all of the bells and whistles) should be easy to do:

load fisheriris            %# load some data
%#meas = zscore(meas);     %# to normalize the attributes
h = plot(meas');            %'# plot
set(gca, 'XTick',1:4, 'XTickLabel',{'SL' 'SW' 'PL' 'PW'}, 'XGrid','on')
ylabel('feature value'), title('Parallel Coordinates')

%# color according to class label
c = grp2idx(species);
clr = lines( numel(c) );
arrayfun(@(k) set(h(c==k),'Color',clr(k,:)), unique(c))

Costas Bouyioukos

The MASS package (available to most of the R installations) includes an implementation for parallel coordinates. The function parcoord.

From the examples of the ?parcoord -a bit corrected- for the Iris data set:

ir <- rbind(iris3[,,1], iris3[,,2], iris3[,,3])
parcoord(log(ir)[, c(1, 2, 3, 4)], col = 1 + (0:149)%/%50)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!