Message Boards Message Boards

GROUPS:

Make ListDensityPlot cover a full rectangle area

Posted 11 days ago
255 Views
|
6 Replies
|
0 Total Likes
|

I've taken this piece of code from the documentation:

data = Table[Sin[i + j], {j, 0, 2 Pi, 0.5}, {i, -1, 1}];
ListDensityPlot[data, Mesh -> All]

I am working in something similar, but I want to make the ListDensityPlot to cover the full rectangle showed in the plot (no white space). Can anyone help me?

Thank you in advance for any help!

6 Replies
Posted 11 days ago
data = Table[Sin[i + j], {j, 0, 2 Pi, 0.5}, {i, -1, 1}];
ListDensityPlot[data, Mesh -> All,  Prolog -> {Blue, Rectangle[{-1, -1}, {1, 1}]}]

enter image description here

Thank you for your answer!

I was thinking about an extension of the interpolation done to cover the full rectangle.

Posted 10 days ago

OK. Try by adding corner points to the list:

data = Table[Sin[i + j], {j, 0, 2 Pi, 0.5}, {i, -1, 1}];
corners = {{-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {-1, 1, 0}};
ListDensityPlot[Join[data, corners], Mesh -> All]

enter image description here

Ok, I don't know why but using InterpolationOrder->0 it works.

Posted 10 days ago

Yes, InterpolationOrder->0 does make the plot cover the whole square. But then it looks a bit strange:

enter image description here

Yes, it's true. It looks a bit weird. However, in my case study it seems to fit well.

It'd be nice if there were an option to full the rectangle with a higher interpolation order though.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract