1
$\begingroup$

I am stuck in how to fix color region of a bar legend after removing many points in a datalist. I think it is easier to understand with MWE. First of all, I have generated 1000 points with the below code.

datalist={};
Do[
a=RandomReal[{1,100}];
b=RandomReal[{1,100}];
c=RandomReal[{1,100}];
AppendTo[datalist,{"a"->a,"b"->b,"c"->c}],{i,1,10^3}]

Using the code, I have generated 10^3 points and drawn a ListPointPlot3D with the points as follows:

Legended[ListPointPlot3D[({"a", "b", "c"} /. datalist), 
ColorFunction -> "AvocadoColors", ViewPoint -> {0, 0, \[Infinity]}, 
Axes -> {True, True, False}, LabelStyle -> 14, PlotRange -> All, 
PlotStyle -> Directive[PointSize[0.015]], 
TicksStyle -> Directive[Black, Bold, Thick], 
AxesStyle -> Directive[Thick], 
FaceGrids -> {{0, 0, 1}, {0, 0, -1}}], 
Placed[BarLegend[{"AvocadoColors", {Min["c" /. datalist], 
Max["c" /. datalist]}}, LabelStyle -> Directive[FontSize -> 12], 
"TicksStyle" -> 
Directive[FontColor -> Black, Bold, AbsoluteThickness[2]]], {1.00,
0.60}]]

Then I got a plot attached.

enter image description here

And then I excluded some points which does not satisfy a condition c<50 in the datalist.

Excludec[datalist_]:=Block[{result,dataset,i,ap,bp,cp},
dataset=Reap[
Table[
cp="c"/.datalist[[i]];
Which[cp<50,Sow[datalist[[i]],ap],
cp>=50,Sow[datalist[[i]],bp]];,
{i,Length[datalist]}],_,Rule][[2]];
result={ap/.dataset,bp/.dataset};
Return[result]]

Using the exclusion code, I collected points which only satisfy the condition.

{good,bad}=Excludec[datalist]

Then, I got nearly half of the total points and then drew another ListPointPlot3D with the reduced number of points.

Legended[ListPointPlot3D[({"a", "b", "c"} /. good), 
ColorFunction -> "AvocadoColors", ViewPoint -> {0, 0, \[Infinity]}, 
Axes -> {True, True, False}, LabelStyle -> 14, PlotRange -> All, 
PlotStyle -> Directive[PointSize[0.015]], 
TicksStyle -> Directive[Black, Bold, Thick], 
AxesStyle -> Directive[Thick], 
FaceGrids -> {{0, 0, 1}, {0, 0, -1}}], 
Placed[BarLegend[{"AvocadoColors", {Min["c" /. good], 
Max["c" /. good]}}, LabelStyle -> Directive[FontSize -> 12], 
"TicksStyle" -> 
Directive[FontColor -> Black, Bold, AbsoluteThickness[2]]], {1.00,
0.60}]]

Then I got another plot attached.

enter image description here

What I want to know here is how to make the color region of the original bar legend consistent with that of the renewed plot with the reduced number of points?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.