1
$\begingroup$

(Using Mathematica 10)

When using ListDensityPlot to plot 40000 + data points, the produced plot seems to be blurred/incorrect for points occurring later in the list.

For instance, in the following code, a dataset is imported (data available as txt file here (ListDensityPlot data)) and plotted using ListDensityPlot over the entire range of data. Points later on the x-axis appear `fuzzy'.

Following this, the same data is split into three segments and these segments plotted separately. It is clear that the data appears different (a more detailed investigation shows the divided data is plotted correctly).

    (*Load in the text file, 
  entries in form {x, y, z} 40602 data points on grid.  
   402 segments in x and 101 in y*)

densityList = 
  Import["minimal_working_densityList.txt", "Data"];

(*Plot All data using List density Plot*)

ListDensityPlot[densityList, AspectRatio -> 1, 
 PlotRange -> {{0, 400}, All, All}]

(*Plot 1st 200 x-values followed by final 200 x values; show together \
- observe difference with 1st plot*)

Show[
 ListDensityPlot[densityList[[1 ;; (200*101)]], AspectRatio -> 1, 
  PlotRange -> {{0, 400}, All, All}],
 ListDensityPlot[
  densityList[[(Length[densityList] - (200*101) + 1) ;; 
     Length[densityList]]], AspectRatio -> 1, 
  PlotRange -> {{0, 400}, All, All}]
 ]

(*Plot values as above but now with a third plot `filling in' the gap \
in x. *)

Show[
 ListDensityPlot[densityList[[1 ;; (200*101)]], AspectRatio -> 1, 
  PlotRange -> {{0, 400}, All, All}],
 ListDensityPlot[
  densityList[[(199*101 + 1) ;; (Length[densityList] - (199*101))]], 
  PlotRange -> {{0, 400}, All, All}],
 ListDensityPlot[
  densityList[[(Length[densityList] - (200*101) + 1) ;; 
     Length[densityList]]], AspectRatio -> 1, 
  PlotRange -> {{0, 400}, All, All}]
 ]

The output for this looks as follows.

Mathematica output](https://www.dropbox.com/s/edfm2y9n8ss6nzm/example_plots_listdensityplot.png?dl=0)
![Mathematica output

(Mathematica output)

Notice that the right-hand side of the first plot has not been produced correctly/clearly.

$\endgroup$
  • $\begingroup$ Not related to ListDensityPlot, but I'm noticing that your data is rectangularly-spaced, so you could convert it into matrix form, plot it using Image or ArrayPlot and apply a DataRange. $\endgroup$ – DumpsterDoofus Jan 31 '15 at 2:33
  • $\begingroup$ Dang, just realized DataRange doesn't work with ArrayPlot. You can still convert it into array form, like this: arr = ConstantArray[0, {402, 101}]; (arr[[#[[1]], Round[100 #[[2]] + 1]]] = #[[3]]) & /@ densityList; MatrixPlot[arr]. $\endgroup$ – DumpsterDoofus Jan 31 '15 at 2:41
  • $\begingroup$ Great, this is an awesome workaround. Thanks for your help! $\endgroup$ – GeoWA Feb 2 '15 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.