0
$\begingroup$

I have experimental data in the structure of thousands of {x,y} set. So, I want to get the 2D histogram of x and y. I found the Function called DensityPlot and DensityHistogram. The former seemed that I have to count each {x,y} set and make 3D data {x,y,count}. So I tried the latter, DensityHistogram.

I have two questions.

Q1. If preparing data by

   placex = RandomInteger[{-100, 100}, 10000];
   placex2 = RandomInteger[{-10, 10}, 100000];
   xjoin = Join[placex, placex2];
   placey = RandomInteger[{-100, 100}, 10000];
   placey2 = RandomInteger[{-5, 5}, 100000];
   yjoin = Join[placey, placey2];
   data = Transpose[{xjoin, yjoin}];

I can make the DensityHistogram as follows,

LargeHist = DensityHistogram[data, 50, PlotRange -> {{-100, 100}, {-100, 100}, {0, 50000}}, ChartLegends -> Automatic, ColorFunction -> (ColorData["Rainbow"][Rescale[#, {0, 10000}]] &), ColorFunctionScaling -> False]

SmallHist = DensityHistogram[data, 50, PlotRange -> {{-100, 100}, {-100, 100}, {0, 50000}}, ChartLegends -> Automatic, ColorFunction -> (ColorData["Rainbow"][Rescale[#, {0, 100}]] &), ColorFunctionScaling -> False]

The problem is that I can change the range of ColorFunction but the range of ChartLegends cannot be changed. I mean, ChartLegend in "LargeHist" is proper, but the ChartLegend of "SmallHist" doesn't visualize color in detail for small population... I want to enlarge the ChartLegend of under 500 in population in "SmallHist". Do you know how to change the range of ChartLegends??

Q2. Is it possible to annotate each position, like the figure of this page? https://stackoverflow.com/questions/11917547/how-to-annotate-heatmap-with-text-in-matplotlib

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.