I have a data file with triplets. The first two numbers indicate the x and y position, while the third one is the log10 value of a particular indicator. I want to create a 2D plot in which the positions are plotted and assigned colors according to the value of the third number. I think the best solution is to use ListContourPlot
or ListDensityPlot
. I tried the first one and I managed to create the plot I wanted. However, there is problem which I cannot solve. I provide the corresponding Mathematica code. Unfortunately, I don't know how to upload the data file. The black dots correspond to the points. As you can see, there is a region with "bad" colors in which there are no points at all in the data file, but the algorithm is trying to spread the colors in that region. How could I fix this? I want to restrict colors to the data.
ListContourPlot[dataMLCN,
ContourShading -> Automatic,
ContourStyle -> None,
InterpolationOrder -> 5,
ColorFunction -> "Rainbow",
PlotLegends ->
Placed[
BarLegend[Automatic,
LegendMargins -> {{0, 0}, {10, 5}},
LegendLabel -> "\!\(\*SubscriptBox[\(log\), \(10\)]\)(MLCN)",
LabelStyle -> {FontSize -> 15, FontFamily -> "Helvetica"}],
Right],
PerformanceGoal -> "Quality",
FrameLabel -> {"R", OverDot["R"]},
RotateLabel -> False,
LabelStyle -> Directive[FontSize -> 17, FontFamily -> "Helvetica"],
Contours -> 200,
ImageSize -> 500]
Code and data files
Apparently it's not possible at this moment to easily upload files to the StackMMA attachment repository (see this Meta question). Therfore I share the above mentioned files in the following way.
The files will be automatically opened in a file system browser (at least on Windows) by executing the following single line of code in Mathematica (this method is describe here):
SystemOpen[Export[FileNameJoin[{$TemporaryDirectory, "StackMMATempFile.zip"}], Uncompress@FromCharacterCode@Flatten@ImageData[Import["https://i.stack.imgur.com/SiCSP.png"], "Byte"], "Byte"]]
[Sjoerd]