Correct way to (un)zip arrays in Julia

Viewed 1826

I was using the PyPlot library in Julia for plotting, and the scatter function seems to have a "little" inconvenience, namely, that only accepts the coordinates as two arguments: one array for all x values, and another for all y values, i.e.

scatter(xxs,yys)

with x=[x1,x2,...], and y=[y1,y2,...].

If I have a set or a tuple with points of coordinates, like,

A=([x1,y1],[x2,y2],...)

using pyplot/matplotlib directly in Python solves the inconvenience in one liner, as atested here in StackOverflow:

plt.scatter(*zip(*li))

but it seems that zip on Julia works completely different. Until now, I have come with following solution, but it seems quite inelegant:

x=[]
y=[]
for j in selectos
  append!(x,j[2])
   append!(y,j[1])
end

scatter(x,y, marker="o",c="black")

Is there a more "functional" or one-liner (or two liner) approach?

2 Answers
Related