7
$\begingroup$

I stumbled across this in the Mathematica documentation and thought it was pretty nifty except that the Histogram that appears as the plot legend is too small so the numbers on the histogram overwrite each other. How do you control the size of the histogram and it's annotation? I tried using LegendSize->2 and LegendSize->{2,2} but these failed. I also tried Needs["PlotLegends`"] to no avail.

counties = EntityValue[Entity["AdministrativeDivision", {_,"Texas" | "NewMexico" | "Arizona" | "Nevada" | "California", "UnitedStates"}], "Entities"];
vals = EntityValue[counties, "PerCapitaIncome"];
pci = GeoRegionValuePlot[Thread[counties -> vals], PlotLegends -> Histogram]
$\endgroup$
1
  • $\begingroup$ The above code fails for me on V13.0. Anyone else having this problem? $\endgroup$ Commented Mar 7, 2022 at 2:07

3 Answers 3

3
$\begingroup$

In response to the Comment by @JEP, an alternative is to extract the two graphics and the caption from the original quantity, pci, in the Question

p1 = pci[[1]]
p2 = pci[[2, 1, 1, 1]]
caption = pci[[2, 1, 1, 2]]

and then combine them as desired. For instance,

Grid[{{Show[p1, ImageSize -> 360], Show[p2, ImageSize -> 250]}, {SpanFromAbove, caption}}]

plot

$\endgroup$
7
$\begingroup$

Rather than making the Histogram larger, I suggest you measure vals in terms of $1000. Replace your last line by

pci = GeoRegionValuePlot[Thread[counties -> Quantity[QuantityMagnitude[vals/1000], 
     IndependentUnit["$K per year"]]], PlotLegends -> Histogram]

Dividing vals by 1000 expresses quantities in units of $1000. IndependentUnit["$K per year"] provides the label on the Histogram axis.

Histogram Legend

$\endgroup$
2
  • $\begingroup$ This is a good work-around for the specific example at hand but my question was really one of principle. How do you control the size of the histogram? $\endgroup$
    – JEP
    Commented Jan 19, 2015 at 2:05
  • $\begingroup$ @JEP, one approach is the method shown in my second answer. There probably are others. $\endgroup$
    – bbgodfrey
    Commented Jan 19, 2015 at 16:51
3
$\begingroup$

You can interactively resize the histogram Graphics with the drag handles:

enter image description here

Or programmatically, using the part spec as in bbgodfrey's second answer:

MapAt[Show[#, ImageSize -> 350] &, pci, {2, 1, 1, 1}]
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.