In radiation therapy, we display radiation dose as an isodose contour plot overlain on density plot describing the patient geometry (CT data). Here is a simple example (the material grid is voxelated and appears in grayscale & the isodose lines are shown in color overlaying the geometry voxels):
You can see that the left and right sides of the symmetric geometry are placed differently.
In Mathematica, i would like to show a ListContourPlot
over a ListDensityPlot
(or a Raster
, or an ArrayPlot
or a ListContourPlot
with InterpolationOrder->0
).
The challenge, is that the higher interpolation orders do not align with the zero order. Here is a simple example, where the same array might be expected to align using the ListDensityPlot
and ListContourPlot
. But this does not happen because the Density Plot is being done with interpolation order of zero.
iMax = 10;
plotData = Table[If[x == 5 || y == 5, 1, 0], {x, 1, iMax}, {y, 1, iMax}];
Show[{
ListDensityPlot[plotData
, InterpolationOrder -> 0
, ColorFunction -> GrayLevel
]
,ListContourPlot[plotData
, InterpolationOrder -> 1
, Contours -> 1
, ContourShading -> False
, ContourStyle -> {Red}
]
}]
Which results in:
My goal is to have the red contours centered on the white white cross.
I have tried using Inset
and Raster
as well as overlaying two ListContourPlots
. Each approach has it's own challenges. I would prefer to keep the List
plotting functions for speed and not have to create interpolating functions of the dose and geometry.
Any suggestions for strategies to get these plots aligned?
Thank you!
Looking at the same code with first order interpolation:
iMax = 10;
plotData =
Table[If[x == 5 || y == 5, 1, 0], {x, 1, iMax}, {y, 1, iMax}];
Show[{
ListContourPlot[plotData
, InterpolationOrder -> 1
, ColorFunction -> GrayLevel
]
, ListContourPlot[plotData
, InterpolationOrder -> 1
, Contours -> {0.5}
, ContourShading -> False
, ContourStyle -> {{Thick, Red}}
]
}]
Results in the image below:
The material grid (which are cubes) are now shown in a manner which does not cover their true extent.
ContourShading
inContourPlot
and get rid of the density plot altogether? Try getting rid ofContourShading -> False
and addColorFunction -> GrayLevel
. $\endgroup$