6
$\begingroup$

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?

$\endgroup$
2
  • 1
    $\begingroup$ 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]] ? $\endgroup$
    – kglr
    Jan 2, 2021 at 7:26
  • 1
    $\begingroup$ ... and GridLines -> {None, {9.02}} instead of Epilog ->Inset[...]? $\endgroup$
    – kglr
    Jan 2, 2021 at 7:27

1 Answer 1

10
$\begingroup$

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

$\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.