3
$\begingroup$

I have a irregularly placed measurement data. I bring here a small example. I am sorry for that.

mdata = {{20., 1.6, 0.218084}, {4.02807, 1.71068, 0.227565}, {19., 1.6, 0.240074}, {18.8333, 1.60667, 0.278783}, {17.5, 1.62, 0.406884}, {21.9127, 1.72134, 0.427501}, {16.89, 1.61925, 0.438591}, {7.22189, 1.70931, 0.455631}, {16.1132, 1.62516, 0.515403}, {8.51871, 1.68045, 0.524135}, {8.4419, 1.69226, 0.531889}, {9.6625, 1.68612, 0.601701}, {14.1699, 1.63774, 0.639421}, {14.5437, 1.63975, 0.65735}, {13.5583, 1.64633, 0.700959}, {11.9613, 1.66151, 0.704242}, {11.276, 1.67761, 0.706502}, {12.9152, 1.65519, 0.718618}, {12.3724, 1.66034, 0.719962}, {12.2406, 1.66432, 0.724829}, {12.9876, 1.6586, 0.734248}, {13.1918, 1.65804, 0.750541}, {13.8071, 1.6563, 0.754093}, {13.1619, 1.66528, 0.759312}, {13.111, 1.66365, 0.764214}, {13.2852, 1.67032, 0.787843}, {14.4106, 1.6628, 0.805543}, {22.6391, 1.68181, 0.810923}, {13.9972, 1.7042, 0.817875}, {14.8398, 1.66263, 0.818304}, {22.2249, 1.68764, 0.824216}, {19.9883, 1.70148, 0.827452}, {16.1394, 1.66178, 0.840096}, {15.3544, 1.67243, 0.873424}, {15.6949, 1.67557, 0.903093}};

ListContourPlot[mdata, Mesh -> All]

problematic listContourPlot

So the data is not so bad, but the traingulation(?) of the mesh looks ugly. It seems to be issue with the aspect ration of the data as the fallowing plot looks much better:

ListContourPlot[{1, 100, 1} (# - {0, 1.6, 0}) & /@ mdata, Mesh -> All]

hack1

The downside of this trick is, that now I will have to implement the y axes label override in order to show the correct numbers. Is there a smarter workaround?

Weakly related is Smoothing ListContourPlot contours but it is about data smoothing. I want to show the actual data.

I have the same issue with both Mathematica 8&9.

EDIT

Here is my attempt using overriding the tick labels.

rescaleParams = {1, 100, 1};
dataRanges = {Min@#, Max@#} & /@ (Transpose[mdata][[{1, 2}]]);
tickF[rescaleParam_, min_, max_] := {rescaleParam #, N@#} & /@ 
   FindDivisions[{min, max}, 5];
ListContourPlot[rescaleParams # & /@ mdata, Mesh -> All, 
 FrameTicks -> 
  MapThread[
   tickF, {rescaleParams[[{1, 2}]], dataRanges[[;; , 1]], 
    dataRanges[[;; , 2]]}]]

enter image description here

As I was afraid, it is messy. It is also problematic in the case I want to combine it with some other plots using Show. If you made this override method more elegant or at least improve the rounding of the tick labels, it would be appreciated as well.

$\endgroup$
  • 1
    $\begingroup$ Look up FindDivisions for choosing tick positions. $\endgroup$ – Simon Woods Jun 21 '14 at 12:42
  • $\begingroup$ @SimonWoods Thanks! I have reimplemented this thing like so many times. The example is now updated. I still like Belisarius' answer more though. Let's see if he cares to provide any more comments. $\endgroup$ – Johu Jun 23 '14 at 22:06
6
$\begingroup$

Don't take it too seriously, it's just a trick:

a = ListContourPlot[mdata, Mesh -> All]; 
b = ListContourPlot[{1, 100, 1} # & /@ mdata, Mesh -> All];
gcB = Cases[b, GraphicsComplex[l_, p_] :>GraphicsComplex[{1, 1/100} # &/@ l, p]];
a /. GraphicsComplex[___] :> gcB

Mathematica graphics

$\endgroup$
  • $\begingroup$ Fancy. Could you comment on possible pitfalls of the method? It can be overlay using Show using the 'correct' coordinates, right? atm it seems nicer than the label override I added to the question. $\endgroup$ – Johu Jun 21 '14 at 11:27
  • 1
    $\begingroup$ The method can be simplified to Show[ListContourPlot[{1,100,1} #&/@mdata,Mesh->All]/.GraphicsComplex[l_,p_]:>GraphicsComplex[{1,1/100} #&/@l,p],PlotRange->All]. $\endgroup$ – Alexey Popkov Jun 24 '14 at 12:57

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.