Let's consider the following simple plot
P0 = Plot[Sin[x], {x, -7, 7}, Frame -> True, Axes -> False, PlotLabel ->
Style["Test 1", FontSize -> 20, Black, FontFamily -> "Helvetica"],
AspectRatio -> 1, ImageSize -> 550];
The second one is much more complicated ad we need to create some data in order to replicate the situation
n = 5000;
data = Table[{RandomReal[], RandomReal[], RandomReal[{10^-2, 10^4}],
RandomInteger[{0, 2}]}, {i, 1, n}];
Define a color function
valrange = {-2, 4};
data[[All, 3]] = Rescale[Log10[data[[All, 3]]], valrange];
colfunc[x_, cf_] := If[x[[4]] == 0, Gray, ColorData[cf][1 - x[[3]]]];
Create a colrbar
Clear[colorbar]
colorbar[{min_, max_}, colorFunction_: Automatic, divs_: 150] :=
DensityPlot[y, {x, 0, 0.1}, {y, min, max}, AspectRatio -> 10,
PlotRangePadding -> 0, PlotPoints -> {2, divs}, MaxRecursion -> 0,
Frame -> True, FrameLabel -> {{None, "test"}, {None, None}},
LabelStyle -> Directive[FontFamily -> "Helvetica", 17],
FrameTicks -> {{None, All}, {None, None}},
FrameTicksStyle -> Directive[FontFamily -> "Helvetica", 15, Plain],
ColorFunction -> colorFunction]
A simple contour
C0 = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}, Contours -> {0.5},
ContourStyle -> {{Black, Thickness[0.005]}}, AspectRatio -> 1,
ContourShading -> False, PlotPoints -> 200,
PerformanceGoal -> "Quality"];
and finally the modified density plot
With[{opts = {ImageSize -> {Automatic, 550}}, cf = "Rainbow"},
Row[{Show[
ListPlot[List /@ data[[All, {1, 2}]],
PlotStyle -> ({PointSize[0.005], colfunc[#, cf]} & /@ data),
AspectRatio -> 1, Frame -> True, RotateLabel -> False,
Axes -> None, FrameTicks -> True, FrameLabel -> {"x", "y"},
LabelStyle -> Directive[FontFamily -> "Helvetica", 20],
ImagePadding -> {{60, 20}, {60, 20}}, opts,
PlotLabel -> Style["Test 2", FontSize -> 20, Black,
FontFamily -> "Helvetica"]], C0, PlotRange -> 0.9,
PlotRangeClipping -> True],
Show[colorbar[valrange, ColorData[cf][1 - #] &],
ImagePadding -> {{20, 60}, {60, 40}}, opts]}]]
There are two issues regarding this second complicated plot:
(a). For large data sets, (n > 10000) the programs needs more than 10 minutes so as to create the plot! Is there any way to speed up the process?
(b). Even though I set PlotRange -> 0.9, PlotRangeClipping -> True, we see that the frame in all directions does not end at exactly 0.9 but in 0.9 + dx. Why?
Now, if we put together the two plot

it becomes evident that size of them do not match. For both plots I used ImageSize -> 550 but it seems that the second one (the complicated) is smaller. I suspect, that this has to so with the colorbar it carries together. So, my question is: how can I get the second plot match in size with the first?
EDIT
Apparently, each (x,y) point should be treated as a separate list by using List /@ data[[All, {1, 2}]]. That's the reason why the code is very slow when we have many points. Unfortunately and strangely enough I cannot use ListDensityPlot simply because stupidly it joins by default the points without giving you an option for that!
List /@ data[[All, {1, 2}]]– Vaggelis_Z Nov 20 '13 at 10:38PlotRangePadding -> 0– Simon Woods Nov 20 '13 at 10:58P0to have a width of 550 pixels, and the complex plot to have a height of 550 pixels, with lots of image padding. If you want the frames to line up use the same settings forImageSizeandImagePaddinginP0as you do in the complex plot. – Simon Woods Nov 20 '13 at 11:00