0
$\begingroup$

Is there any way to place plots/cells side-by-side?

I know how to put plots in arrays and grids.

The motivation for putting cells side by side is that I want the equations for the plots to be above the graph, rather than have a single expression with multiple functions in it. In other words I want an effect like this:

side-by-side-cells

$\endgroup$
  • 3
    $\begingroup$ You have been asking questions on this site for almost two years, but you still post questions lacking many of the details people would need to know in order to understand them. I think it's time for you to put more work into your questions. Unless you can give a cogent example demonstrating why you need to place cells side-by-side and how the result of doing so will achieve something than can't be done by Grid and its ilk, I can see no reason for pursuing this question. $\endgroup$ – m_goldberg Sep 24 '15 at 1:22
  • 1
    $\begingroup$ Take a look at the slide show template, there is a slide with tow side-by-side cells. $\endgroup$ – Markus Roellig Sep 24 '15 at 8:03
  • 1
    $\begingroup$ @m_goldberg I have to disagree. You are quite right that OP's needs may perhaps be satisfied by Grid &c., and a more detailed example of the intent would certainly be useful to help decide what might be an appropriate workaround. But whatever alternatives may exist have no particular bearing on the validity of asking whether it is possible to have side-by-side cells. I upvoted the question. $\endgroup$ – Oleksandr R. Sep 24 '15 at 8:47
  • $\begingroup$ closely related: 30440 $\endgroup$ – Kuba Sep 25 '15 at 11:29
  • $\begingroup$ @OleksandrR. I believe the basic issue m_goldberg describes here is not that the question is not potentially interesting but that the OP does not put effort in providing sufficient context. For instance the "place plots/cells side-by-side" is very confusing. Plots and cells are clearly two different beasts and the OP admits that he knows how to place plots side-by-side. So what's the use of asking this "plots/cells" thing? This is a rather lazy description and the OP shows a pattern of this behavior, at least in the view of m_g (and I tend to agree with him). $\endgroup$ – Sjoerd C. de Vries Dec 8 '15 at 21:22
2
$\begingroup$

I am not sure how cells can be placed in arbitrary arrangements except by placing embedded cells into e.g. Grid, as has already been suggested. But for the case of a simple side-by-side arrangement, one can use the undocumented CellFrameLabels option. It can work as follows:

NotebookWrite[EvaluationNotebook[],
 Cell[BoxData@ToBoxes@Plot[Sin[x], {x, -π, π}, ImageSize -> Scaled[1]],
  CellFrameLabels -> {
    {BoxData@ToBoxes@Plot[Tan[x], {x, -π, π}, ImageSize -> Scaled[1/3]], 
     BoxData@ToBoxes@Plot[ArcCot[x], {x, -π, π}, ImageSize -> Scaled[1/3]]},
    {None, None}
   }
 ]
]

It looks like this:

Three side-by-side cells containing plots of simple trigonometric functions

A potentially relevant point is that the cells that are labels are not permitted to have their own CellFrameLabels. If these are specified, they are simply ignored. So, if you want more than three cells side-by-side, I don't know any better way than to use a Grid.

$\endgroup$
  • $\begingroup$ Would this allow me to put [In] formulas side by side (as shown in question)? $\endgroup$ – Tyler Durden Dec 8 '15 at 22:53
  • $\begingroup$ @TylerDurden probably not. You can do it (sort of) using the AuthorTools package function MakeBilateral. But this basically just produces a GridBox containing cells, which you can do yourself. It would be helpful if you can elaborate why you are opposed to making a grid. $\endgroup$ – Oleksandr R. Dec 8 '15 at 23:18
  • $\begingroup$ Because you cannot put formulas (In cells) inside of Grids. Only the Output of a cell can be in a Grid. I want to show many examples of Mathematica formulas in a compact way and do not want to retypte text versions of the formulas in the grid boxes as labels. I want to have the actual formula for the plot IN the area itself. $\endgroup$ – Tyler Durden Dec 9 '15 at 14:08
  • $\begingroup$ @TylerDurden I think you should brush up on your notebook programming. You would be surprised what can be in a GridBox. $\endgroup$ – Oleksandr R. Dec 9 '15 at 14:16
0
$\begingroup$

I think GraphicsGrid is the simplest option. As for equation above each, use PlotLabel in each.

p1 = Plot[Sin[x], {x, -Pi, Pi}, PlotLabel -> Sin[x]];
p2 = Plot[Tan[x], {x, -Pi, Pi}, PlotLabel -> Tan[x]];
Show[GraphicsGrid[{{p1, p2}}]]

result

$\endgroup$
  • $\begingroup$ "I know how to put plots in arrays and grids." - OP $\endgroup$ – Kuba Dec 12 '17 at 10:55
  • $\begingroup$ I forgot to put the labels in each plot... Anyway, I just put that answer here because it took me some minutes to find how to put plots in a grid; so, if someone comes here looking for a way to do that (as I did), here is an answer. $\endgroup$ – Pedro H. N. Vieira Dec 12 '17 at 11:06
0
$\begingroup$

The simplest way is Row@{plot1,Spacer[1],plot2} The Spacer[x] allows the adjustable space between row elements according to the x-value.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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