Short form of Graphics

Sometimes I want to investigate the structure of Graphics/Graphics3D which is produced by Plot/Plot3D or similar command. Often InputForm produces a very big output

Plot[x, {x, 0, 1}] // InputForm
(* Graphics[{{{}, {}, {Directive[Opacity[1.], RGBColor[0.368417, 0.506779,
0.709798], AbsoluteThickness[1.6]], Line[{{2.040816326530612*^-8,
2.040816326530612*^-8}, {0.000306717908041361, 0.000306717908041361},
... points, points, points ...
{0.9999999795918367, 0.9999999795918367}}]}}},
{DisplayFunction -> Identity, AspectRatio -> GoldenRatio^(-1),
Axes -> {True, True}, AxesLabel -> {None, None}, AxesOrigin -> {0, 0},
DisplayFunction :> Identity, Frame -> {{False, False}, {False, False}},
FrameLabel -> {{None, None}, {None, None}},
FrameTicks -> {{Automatic, Automatic}, {Automatic, Automatic}},
GridLines -> {None, None}, GridLinesStyle ->
Directive[GrayLevel[0.5, 0.4]],
Method -> {"DefaultBoundaryStyle" -> Automatic,
"ScalingFunctions" -> None}, PlotRange ->
{{0, 1}, {0., 0.9999999795918367}}, PlotRangeClipping -> True,
PlotRangePadding -> {{Scaled[0.02], Scaled[0.02]},
{Scaled[0.05], Scaled[0.05]}}, Ticks -> {Automatic, Automatic}}] *)


What is the simplest way to get a small and informative output?

For example, in version 9 and earlier I can use // InputForm // DeveloperPackedArrayForm

Plot[x, {x, 0, 1}] // InputForm // DeveloperPackedArrayForm

(* Graphics[{{{}, {}, {Hue[0.67, 0.6, 0.6],
Line["PackedArray"[Real, "<"77","2">"]]}}},
{AspectRatio -> GoldenRatio^(-1), Axes -> True, AxesLabel -> {None, None},
AxesOrigin -> {0, 0}, Method -> {}, PlotRange -> {{0, 1}, {0., 0.9999999795918367}},
PlotRangeClipping -> True, PlotRangePadding -> {Scaled[0.02], Scaled[0.02]}}] *)


I see all options and I see the dimensions of a big data arrays. It is not the case for Short or Shallow

Plot[x, {x, 0, 1}] // InputForm // Short
(* Graphics[{{{}, {}, {Directive[<<3>>], Line[{<<77>>}]}}}, {<<16>>}] *)


However, in V10 DeveloperPackedArrayForm produces a mess with InputForm

Plot[x, {x, 0, 1}] // InputForm // DeveloperPackedArrayForm
(* Graphics[{{{}, {}, {Directive[Opacity[1.], RGBColor[0.368417, 0.506779, 0.709798],
AbsoluteThickness[1.6]], Line["PackedArray"[Real, Row[{Style["<",
ShowStringCharacters -> False, StripOnInput -> True], Row[{77,
Style[",", ShowStringCharacters -> False], 2}, StripOnInput -> True],
Style[">", ShowStringCharacters -> False, StripOnInput -> True]},
StripOnInput -> True]]]}}},
{DisplayFunction -> Identity, AspectRatio -> GoldenRatio^(-1), Axes -> {True, True},
AxesLabel -> {None, None}, AxesOrigin -> {0, 0}, DisplayFunction :> Identity,
Frame -> {{False, False}, {False, False}}, FrameLabel -> {{None, None}, {None, None}},
FrameTicks -> {{Automatic, Automatic}, {Automatic, Automatic}},
GridLines -> {None, None}, GridLinesStyle -> Directive[GrayLevel[0.5, 0.4]],
Method -> {"DefaultBoundaryStyle" -> Automatic, "ScalingFunctions" -> None},
PlotRange -> {{0, 1}, {0., 0.9999999795918367}}, PlotRangeClipping -> True,
PlotRangePadding -> {{Scaled[0.02], Scaled[0.02]}, {Scaled[0.05], Scaled[0.05]}},
Ticks -> {Automatic, Automatic}}] *)


Could you propose an alternative approach? May be I miss something very simple. I don't want to write a complicated parser. The main goal is to do it as fast and simple as possible.

• related
– Kuba
Sep 18 '14 at 17:08
• How about Plot[x, {x, 0, 1}] // InputForm // Short? Or, if you need more control, Short[InputForm[Plot[x, {x, 0, 1}]], 10]. Sep 18 '14 at 17:10
• @MarkMcClure As I show in the post, it hides the options. Options are more significant for the graphics then the particular values of the data. It is not convenient to find every time a threshold for Short which will show the options and do not show a lot of points. Sep 18 '14 at 17:18
• Sorry, I posted a comment since I looked at your post quite quickly. Does Plot[x, {x, 0, 1}] // Options help? Sep 18 '14 at 17:24
• @MarkMcClure Sometimes it can help. However, suddenly I find a simple solution, which I posted as the answer. Sep 18 '14 at 17:44

2 Answers

I find a simple version-independent solution, which produces a very clear output

List @@ Plot[x, {x, 0, 1}] // DeveloperPackedArrayForm


Moreover, it allows a brackets-matching and a multiple-click highlighting!

show = {Short@First@#, Last@#} &;

Plot[x, {x, 0, 1}] // show
`

• Nice! I added the snapshot. I hope you don't mind. Sep 18 '14 at 17:59