2
$\begingroup$

When I am trying to use PlotRangePadding with a fixed range (not symmetric with x and y axes) for a graphic generated by ListContourPlot, it is coming back with an error message that PlotRangePadding can only be either automatic or none.

Following is a small code to demonstrate the problem. Here, I want a padding at the bottom only, not a symmetric one around the whole graphic.

Will be thankful for any suggestion.

XX={{0.,0.,14},{0.,0.,2},{0.149508,0.076178,7},{0.153488,0.0498713,7},{0.156435,0.,4},{0.302952,0.0984348,7},{0.309017,0.,4},{0.444473,0.144418,7},{0.451668,0.0715374,7},{0.453991,0.,4},{0.574342,0.186615,8},{0.584501,0.0925761,7},{0.587786,0.,4},{0.689152,0.223919,8},{0.702713,0.111299,7},{0.707107,0.,4}};
    ListContourPlot[XX,ColorFunction->"TemperatureMap",PlotLegends->Placed[BarLegend[{0, 17, 34, 51, 67},LegendMargins->{{0,0},{10,5}},LegendLabel->"% output",LegendMarkerSize->150, LabelStyle->{Italic,Bold, FontSize->15, FontFamily->"Helvetica"}],{{0.1, 0.5}, {0.1, 0.1}}],PlotRangePadding->{{0, 0}, {0.1, 0}}, Frame -> False, BoundaryStyle->{Black, Thick}]
$\endgroup$
3
  • 1
    $\begingroup$ user49535, you have not accepted any of the answers to your 37 questions over more than 2 years. May I suggest that you revisit your questions on the linked page to consider accepting answers or provide guidance on why none of the answers are not acceptable. $\endgroup$
    – kglr
    Commented Oct 16, 2019 at 12:42
  • $\begingroup$ This is a bug. I recommend you report it to support. $\endgroup$
    – Carl Woll
    Commented Oct 16, 2019 at 21:23
  • $\begingroup$ I just figured out how to do it. Will do for all good answers in past. Thanks for letting me know about it. $\endgroup$
    – user49535
    Commented Oct 17, 2019 at 8:24

2 Answers 2

1
$\begingroup$

It seems that PlotRangePadding is hard-coded into ListContourPlot and Mathematica doesn't allow one to change this. But we can play with PlotRange:

ListContourPlot[XX, ColorFunction -> "TemperatureMap", 
PlotLegends -> 
Placed[BarLegend[{0, 17, 34, 51, 67}, 
LegendMargins -> {{0, 0}, {10, 5}}, LegendLabel -> "% output", 
LegendMarkerSize -> 100, 
LabelStyle -> {Italic, Bold, FontSize -> 15, 
  FontFamily -> "Helvetica"}], {{0.1, 0.6}, {0.1, 0.1}}], 
Frame -> True, BoundaryStyle -> {Black, Thick}, 
PlotRange -> {All, {-0.1, All}}]

Maybe this is what you want.

enter image description here

$\endgroup$
2
  • $\begingroup$ PlotRange Worked !! Thanks a lot. $\endgroup$
    – user49535
    Commented Oct 17, 2019 at 5:21
  • $\begingroup$ For the same graphic, how to smoothen the boundaries between two colors (contours) ? I tried InterpolationOrder from 1-10, but does not seem to make any difference !! $\endgroup$
    – user49535
    Commented Oct 17, 2019 at 8:28
2
$\begingroup$

Update: A work-around: Post-processing to replace the option value for PlotRangePadding (which, strangely, is {{Scaled[0.02],Scaled[0.02]},{Scaled[0.02],Scaled[0.02]}} regardless of how the user sets this option)

lcp1 = ListContourPlot[XX, ColorFunction -> "TemperatureMap", 
    PlotLegends -> Placed[BarLegend[{0, 17, 34, 51, 67}, 
      LegendMargins -> {{0, 0}, {10, 5}}, 
      LegendLabel -> "% output", LegendMarkerSize -> 150, 
      LabelStyle -> {Italic, Bold, FontSize -> 15, FontFamily -> "Helvetica"}], 
    {{0.1, 0.5}, {0.1, 0.1}}], 
   Frame -> False,
   BoundaryStyle -> {Black, Thick}, Axes -> True];

lcp1 /. HoldPattern[PlotRangePadding -> _] :> (PlotRangePadding -> {{0, 0}, {.1, 0}})

enter image description here

Original answer:

Using

PlotRangePadding -> {{0, 0}, {0.1, 0}, Automatic}

eliminates the error message and gives

enter image description here

However, PlotRangePadding option values are simply ignored by ListContourPlot3D.

$\endgroup$
2
  • 1
    $\begingroup$ Thanks ! It is not coming back with a error message now, but actually there is no padding below (or any other side) by using {{0, 0}, {0.1, 0}, Automatic}. $\endgroup$
    – user49535
    Commented Oct 16, 2019 at 12:37
  • $\begingroup$ @user49535, you are right; that's strange. $\endgroup$
    – kglr
    Commented Oct 16, 2019 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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