1
$\begingroup$

I've been trying to get ListContourPlot to work for me on a large set of data, and I feel like I'm failing at the most basic parts of formatting. I've tried piecing together bits of code from here and the documentation, but at this point I've dumped hours into what should be a very simple labeling task.

perfcontourlarge = ListContourPlot[contourdata, PlotRange -> {{0, 2}, {0, 2.5}},   Contours -> {0.2, 0.7, 1, 1.2, 1.4, 1.5, 1.6}, ContourLabels -> (Text[#3, {#1, #2}, Background -> White] &), ContourShading -> False,   BaseStyle -> {Thick, Black, FontSize -> 16}, LabelStyle -> {16, GrayLevel[0]}]

The above yields the image below, with many of the labels missing. Changing which contour lines I want, or allowing Mathematica to pick them automatically, still cuts off labeling for some (seemingly) random subset of lines.

After copy/pasting the graphic into a text editor to examine the full code, I suspect that the labels are being placed outside the plot area. I have no idea how to fix this. Any help would be greatly appreciated!

Contour Plot missing labels

$\endgroup$
  • 2
    $\begingroup$ If you want to inspect the code for a plot, you can use InputForm[plot] or FullForm[plot] where plot can either be the copy-pasted graphic or else the variable the graphic is assigned to. As for the labels, if you remove PlotRange do all of the labels show up? My guess is that the contours are being labelled somewhere off the edge of what is shown. You might be able to get around that by trimming your dataset down to the range of {{0, 2}, {0, 2.5}} first. $\endgroup$ – MassDefect Oct 10 at 0:43
  • $\begingroup$ Thank you! Trimming the dataset was the way to go! Removing PlotRange did allow the labels to all show up, many at the edges of the plot. I was able to trim my data ahead of the above plotting code using: contourdatatrimmed = Cases[contourdata, {n_, __, __} /; n <= 2]; contourdatatrimmed = Cases[contourdatatrimmed, {__, n_, __} /; n <= 2.5]; $\endgroup$ – James Oct 10 at 0:47
  • $\begingroup$ I'm glad it worked out! $\endgroup$ – MassDefect Oct 10 at 1: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.