 # making points cross in simple plots

hi all,

when plotting a simple scatter plot in matlab, points that overlap will cross in each other – if i plot

scatter(randn(1,1000),randn(1,1000))

then no point will be fully “on top” of the other – if they overlap, then their edges will cross and they will look like tiny venn diagrams.

in matplotlib, this is not the case, and points that overlap are placed on top of each other. for example if i use:
x = randn(1,1000)
plot(x, x, ‘bo’)

how can i fix it so that it looks like matlab and points cross?

more importantly, the above command in matplotlib generates many many line objects and takes forever to render. if i don’t specify ‘bo’ and simply call plot(x, x, ‘o’) it makes every point in a different color. why is that? how can i change that? i feel like i must be doing something wrong here.

thanks.

per freem wrote:

hi all,

when plotting a simple scatter plot in matlab, points that overlap will cross in each other -- if i plot

scatter(randn(1,1000),randn(1,1000))

then no point will be fully "on top" of the other -- if they overlap, then their edges will cross and they will look like tiny venn diagrams.

in matplotlib, this is not the case, and points that overlap are placed on top of each other. for example if i use:
x = randn(1,1000)
plot(x, x, 'bo')

how can i fix it so that it looks like matlab and points cross?

So you want the interiors of the points to be transparent? Add the keyword argument mfc='none'. I may be misunderstanding the desired effect, however.

more importantly, the above command in matplotlib generates many many line objects and takes forever to render. if i don't specify 'bo' and

Again, you are using 2-D arrays when you should be using 1-D. In matlab, everything is a 2-D matrix (or it used to be, until higher dimensions were clumsily patched in). Numpy is designed to use as many or as few dimensions as you need. Mpl plot(x, y) with x and y being MxN is assuming each of the N columns is a line, so it is plotting N lines--as well as cycling through the colors, one per "line", if you don't explicitly give a color.

simply call plot(x, x, 'o') it makes every point in a *different color*. why is that? how can i change that? i feel like i must be doing something wrong here.

It's just a Matlab hangover--a common malady, painful but rarely fatal.

Eric