3
$\begingroup$

In DensityPlot, how to get rid of the white margin between the figure and the frame so that the figure itself spans the entire domain?

DensityPlot[Sin[x y], {x, -1, 1}, {y, -1, 1}, 
  Frame -> True, 
  ImagePadding -> {{20, 20}, {20, 20}}, 
  ImageSize -> {Automatic, 300}]

sin(xy)

$\endgroup$
5
  • 3
    $\begingroup$ PlotRangePadding -> 0 $\endgroup$
    – Kuba
    May 23, 2014 at 4:32
  • $\begingroup$ It should be noted that specifying non-negative values for PlotRangePadding does not reduce the domain of a plot. It extends the domain so as to include the requested padding. You will see no more of your plot by setting PlotRangePadding to zero or None. You will just make the ticks harder to see. $\endgroup$
    – m_goldberg
    May 23, 2014 at 5:18
  • $\begingroup$ @m_goldberg On that note, I became curious about following: Is it possible to reverse the ticks so they point outward? $\endgroup$
    – joojaa
    May 23, 2014 at 5:46
  • $\begingroup$ @joojaa yes. look up Ticks in the docs. $\endgroup$ May 23, 2014 at 6:08
  • $\begingroup$ @MikeHoneychurch could you vote as a duplicate of: 18807. I've lost my vote, which is retracted now, for "simple mistake". $\endgroup$
    – Kuba
    May 23, 2014 at 6:45

1 Answer 1

6
$\begingroup$

Try this:

    DensityPlot[Sin[x y], {x, -1, 1}, {y, -1, 1}, Frame -> True, 
 ImagePadding -> {{20, 20}, {20, 20}}, ImageSize -> {Automatic, 300}, 
 PlotRangePadding -> 0]

enter image description here

$\endgroup$

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