views:

136

answers:

1

R's qplot function has a nifty alpha parameter for shading coincident points in a scatter plot darker. Here it is in action:

http://www.decisionsciencenews.com/2010/07/01/maps-without-map-packages

I'm wondering how to do the same in Mathematica. Here's code to grab the data from the above article and plot it, without the nifty shading:

data = Rest@Import[
  "http://www.decisionsciencenews.com/wp-content/uploads/2010/07/latlong.zip", 
  "latlong.csv"]

ListPlot[data, PlotRange -> {{-130, -65}, {23.5, 50.5}}, Frame -> True]

The question is, how to add the shading of the points?

+4  A: 

I think this has a few different solutions. If you just want to adjust the opacity of every point you can:

ListPlot[data, PlotRange -> {{-130, -65}, {23.5, 50.5}}, 
 Frame -> True, PlotStyle -> Opacity[0.5]]

This produces a very similar effect as the plot in your link.

Custom color maps based on density are possible but my implementation does not produce pretty graphs yet.

Davorak
That's an awesome solution.
Pillsy
Thanks Davorak, that's perfect. I'd love to see your color maps based on density implementation. How about asking about that as a separate question and then providing the answer? (It seems weird to do that, I know, but it's explicitly encouraged by the creators of StackOverflow.)
dreeves