6

I've done this animated GIF image. The trouble with it is that it gets "dancy" as you can see. For the organization of the items, I'm using the following code:

Enter image description here

Which can be copied here:

TableForm[{
{TableForm[
{{
  Style[Length[c], "Title", 16], Style[Hino[[n]], "Title"]
  }}
, TableAlignments -> Center]},
ListPlot[Table[Count[c, A[[n]]], {n, 1, 26}], AxesOrigin -> {0, 0},
PlotRange -> {{0, 27}, {0, 155}}, ImageSize -> 800,
Filling -> {Axis},
 Epilog ->
Inset[Plot[9.02, {x, 1, 26.1}, ImageSize -> 800,
  PlotRange -> {{0, 27}, {0, 155}}, Axes -> False,
  PlotTheme -> "Monochrome"]], Axes -> False,
PlotStyle -> Directive[Black, PointSize[0.01]]]

}, TableAlignments -> Center]

What can I do to avoid the animation getting "dancy" like this?

Peter Mortensen
  • 759
  • 4
  • 7
Red Banana
  • 5,329
  • 2
  • 29
  • 47
  • 1
    why not get rid of TableForm and simply use ListPlot[...] with the option PlotLabel ->Row[{ Style[Length[c], "Title", 16], Style[Hino[[n]], "Title"] }, Spacer[5]] ? – kglr Jan 02 '21 at 07:26
  • 1
    ... and GridLines -> {None, {9.02}} instead of Epilog ->Inset[...]? – kglr Jan 02 '21 at 07:27

1 Answers1

10

To replicate the dancy plot with fake data:

hino = RandomWord["Noun", 50];

lpdata = RandomInteger[150, 26];

frames = Table[TableForm[{{TableForm[{{Style[RandomInteger[500], "Title", 16], Style[hino[[i]], "Title"]}}, TableAlignments -> Center]}, ListPlot[lpdata, AxesOrigin -> {0, 0}, PlotRange -> {{0, 27}, {0, 155}}, ImageSize -> 500, Filling -> {Axis}, Epilog -> Inset[Plot[9.02, {x, 1, 26.1}, ImageSize -> 500, PlotRange -> {{0, 27}, {0, 155}}, Axes -> False, PlotTheme -> "Monochrome"]], Axes -> False, PlotStyle -> Directive[Black, PointSize[0.01]]]}, TableAlignments -> Center], {i, 50}];

Export["dancingplot.gif", frames, AnimationRepetitions -> Infinity]

enter image description here

If you have to use TableForm you can wrap the inner TableForm with Pane with a specific ImageSize so that the vertical size of the cell does not change depending on whether the title word has characters with ascenders/descenders. That is, use

Pane[TableForm[{{Style[RandomInteger[500], "Title", 16], 
    Style[hino[[i]], "Title"]}}, TableAlignments -> Center], 
 ImageSize -> {300, 50}, Alignment -> Center]

to get

enter image description here

If you don't have to use TableForm, then you can simply use ListPlot with the options PlotLabel and GridLines:

frames3 = Table[ListPlot[lpdata, AxesOrigin -> {0, 0}, 
    PlotRange -> {{0, 27}, {0, 155}}, ImageSize -> 500, 
    Filling -> {Axis}, 
    PlotLabel -> Pane[Row[{Style[RandomInteger[500], "Title", 16], 
        Style[hino[[i]], "Title"]}, Spacer[15]], 
      ImageSize -> {500, 100}, Alignment -> {Center, Center}], 
    GridLines -> {None, {{9.02, Directive[Thick, Black]}}}, 
    Axes -> False, PlotStyle -> Directive[Black, PointSize[0.01]]], {i, 50}];

Export["dancingplot3.gif", frames3, AnimationRepetitions -> Infinity]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896