0
$\begingroup$

The following code results in coordinate axes not showing up. I'd like to understand why that happens and how to fix it. Ideally, there's a way to do it so that I can set the image size and axis parameters once and separately from the plotting code.

g = Graphics[{}, ImageSize -> {1920, 1080}];
g = Show[g,
Table[
ParametricPlot[{(1 + t) Cos[a], Sin[a]}, {a, 0, 2 \[Pi]}, 
 PlotRange -> {{-2.1, 2.1}, {-1.2, 1.2}}, 
 AxesStyle -> {{Black, AbsoluteThickness[5]}, {Black, 
    AbsoluteThickness[5]}}, 
 PlotStyle -> {Black, AbsoluteThickness[12]}],
{t, 0, 1, 1/5}]
];
Magnify[g, .25]
$\endgroup$
1
  • $\begingroup$ coordinate axes not showing up will adding Axes -> True to the Show command do what you want? $\endgroup$
    – Nasser
    May 20, 2019 at 2:01

1 Answer 1

2
$\begingroup$

The use of Show is not necessary since ParametricPlot can handle multiple plots, i.e., you can move the Table inside the ParametricPlot.

g = ParametricPlot[
   Table[{(1 + t) Cos[a], Sin[a]}, {t, 0, 1, 1/5}],
   {a, 0, 2 π},
   PlotStyle -> Directive[Black, AbsoluteThickness[12]],
   PlotRange -> {{-2.1, 2.1}, {-1.2, 1.2}},
   AxesStyle -> Directive[Black, AbsoluteThickness[5]],
   ImageSize -> {1920, 1080}];

Magnify[g, .25]

enter image description here

If you do use Show, move the appropriate options from the ParametricPlot to the Show.

g = Show[
   Table[
    ParametricPlot[{(1 + t) Cos[a], Sin[a]}, {a, 0, 2 π},
     PlotStyle -> Directive[Black, AbsoluteThickness[12]]],
    {t, 0, 1, 1/5}],
   PlotRange -> {{-2.1, 2.1}, {-1.2, 1.2}},
   AxesStyle -> Directive[Black, AbsoluteThickness[5]],
   ImageSize -> {1920, 1080}];

Magnify[g, .25]

enter image description here

$\endgroup$
4
  • $\begingroup$ I don't like this solution because the setting of the ImageSize, axes, etc. begins to float around various parts of the code. Is there a solution where the common attributes of the figure (size, axes, background, aspect ratio, etc.) are set up front and then various pieces of the plot (curves, points, etc.) are introduced afterwards. $\endgroup$
    – Wynne
    May 20, 2019 at 3:51
  • $\begingroup$ @Wynne - I do not understand what you are looking for, The first solution above puts all the options in a single ParametricPlot; there is nothing floating around and no decisions to be made as to which option goes where. $\endgroup$
    – Bob Hanlon
    May 20, 2019 at 4:28
  • $\begingroup$ It's in a ParametricPlot. I want it logically divorced from plotting. The problem with putting it in a ParametricPlot is that if I later decide to insert some element before the parametric plot, then all these settings will no longer be at the top and I'll have to cut them out of the ParametricPlot and insert them into whatever I choose to preceed the parametric plot. $\endgroup$
    – Wynne
    May 20, 2019 at 4:31
  • $\begingroup$ @Wynne - Perhaps you want SetOptions $\endgroup$
    – Bob Hanlon
    May 20, 2019 at 4:35

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.