2
$\begingroup$

(Code based on the answer of @kgrl in the question titled Adding Legend to PieChart).

I have two cases that apparently should result to same image size. The first:

TD = 8 + 12 + 12 + 12 + 33 + (61 + 1/4) + (41 + 1/4)/2 + 
   15/2 + (18 + 3/4) + (18 + 3/4)/2 + 14/2;
CM = 15/2 + (61 + 1/4) + (41 + 1/4)/2 + 
   24 + (3 + 3/4) + (18 + 3/4) + (18 + 3/4)/2 + 14/2 + (24 + 3/4) + 
   9/2;
TP = 2*90;
countsDim = {CM, TD, TP}/(TD + TP + CM);

n = 384 + 179;
labels = Placed[
   Row /@ Thread[{Quantity[Round[100 countsDim], "Percent"], 
      " (" <> ToString@# <> " H)" & /@ {N[(n countsDim[[1]]), 5], 
        N[(n countsDim[[2]]), 5], Round@N[(n countsDim)[[3]]]}}], 
   "RadialOutside"];
legend = Placed[
   SwatchLegend[Automatic, 
    Row /@ Thread[{{"CM ", "TD ", "TP "}, 
       Row[{"(", #, ")"}] & /@ 
        Quantity[Round[100 countsDim], "Percent"]}], 
    LabelStyle -> {FontSize -> 14, FontFamily -> "Latin Modern Roman",
       FontColor -> Black}], {After, Bottom}, Framed];

type = Framed[
  PieChart[countsDim, ChartLabels -> labels, ChartLegends -> legend, 
   PlotRange -> All, 
   LabelStyle -> {FontSize -> 14, FontFamily -> "Latin Modern Roman", 
     FontColor -> Black}, PlotTheme -> "NeonColor", 
   ImageSize -> Medium]]

and the second

L1 = 15 + 33 + 2*(61 + 1/4) + (24 + 3/4) + 2*90 + 12 + 12 + 
   12 + (4 + 1/2)/3;
L2 = (41 + 1/4) + (3 + 3/4) + (4 + 1/2)/3;
L3 = 8 + 24 + (4 + 1/2)/3 + 3*(18 + 3/4) + 14;
countsDim3 = {L1, L2, L3}/(L1 + L2 + L3);
 Nlist = {N[(n countsDim3)[[1]], 5], N[(n countsDim3)[[2]], 4], 
  N[(n countsDim3)[[3]], 5]}

n = 563;
labels = Placed[
   Row /@ Thread[{Quantity[Round[100 countsDim3], "Percent"], 
      " (" <> ToString@# <> " H)" & /@ Nlist}], "RadialOutside"];
legend = Placed[
   SwatchLegend[Automatic, 
    Row /@ Thread[{{"L1 ", "L2 ", "L3 "}, 
       Row[{"(", #, ")"}] & /@ 
        Quantity[Round[100 countsDim3], "Percent"]}], 
    LabelStyle -> {FontSize -> 14, FontFamily -> "Latin Modern Roman",
       FontColor -> Black}], {After, Bottom}, Framed];

niveau = Framed[
  PieChart[countsDim3, ChartLabels -> labels, ChartLegends -> legend, 
   PlotRange -> All, 
   LabelStyle -> {FontSize -> 14, FontFamily -> "Latin Modern Roman", 
     FontColor -> Black}, PlotTheme -> "NeonColor", 
   ImageSize -> Medium]]

However, the two figures do not have the same dimensions

enter image description here

I have a series of similar figures that I want to export to Latex. I have been searching here and elsewhere but I could not find a solution to my question. What should I do in order to get Figures of the same dimensions (this apply to everything-circle, legend, text, etc.)?

$\endgroup$
0

1 Answer 1

2
$\begingroup$

Please try replacing, in each of type and niveau

ImageSize -> Medium

with fixed width and height values, for example

ImageSize -> {300, 240}

Equally sized pie charts

$\endgroup$

Your Answer

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

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