Scatter plot with indication of the density of points
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?
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.
精彩评论