Mathematica Asked on February 18, 2021
I have plots of 6 different figures in a command decon
so that if I use decon[[1]]
I plot the first figure and if I use decon[[2]]
I plot the second figure and so on. The decon
storage of the figures was obtained using the command AppendTo
. The figures look like this after I manually plot each of them in two different rows:
Question:
How can I plot these figures as a one column panel where they share the same x axis (T in celsius) from 40 to 110 and the same y axis (Cp in J/gK) but the y-axis changes for each figure each time, similar to the manual sketch I did below:
Thank you in advanced for your help.
EDIT AND UPDATE
The result of the code done by @MassDefect is exactly what I want. The problem is that it doesn’t work in my case because in his code decon
is generating the ListPlot in a certain way. In my case I already have decon
generated. When I put decon
I get the following (I just changed a,b,c,d,e,f for something else but it is the same):
If I put pg[Transpose[{decon}]]
I get my figures like this:
How can I modify the code so that when I do pg[Transpose[{decon}]]
in my case it works?
If I've understood, it seems like you just want a variation of the answer you received in Plot Figures in two columns.
ResourceFunction["PlotGrid"][
{
{Plot[x, {x, 0, 1}, Frame -> True,
PlotLabel -> "Some Label"]}, {Plot[x, {x, 0, 1}, Frame -> True,
PlotLabel -> "Some Label"]}, {Plot[x^2, {x, 0, 1}, Frame -> True,
PlotLabel -> "Some Label"]}, {Plot[x^2, {x, 0, 1}, Frame -> True,
PlotLabel -> "Some Label"]}
}, Spacings -> {0, 30}]
Essentially each grid row has a single element.
You can adjust Spacings
to overlap Axes
labels and show a single Axis
on the bottom graph.
In response to comments...
decon =
{{Plot[x, {x, 0, 1}, Ticks -> {None, Automatic}, Frame -> {False, True, True, True}]},
{Plot[x, {x, 0, 1}, Ticks -> {None, Automatic}, Frame -> {False, True, True, True}]},
{Plot[x^2, {x, 0, 1}, Ticks -> {None, Automatic}, Frame -> {False, True, True, True}]},
{Plot[x^2, {x, 0, 1}, Frame -> True, FrameLabel -> "Some Label"]}}
ResourceFunction["PlotGrid"][decon, Spacings -> {0, 2}]
You need to do some recasting of decon
along the lines I have set out above. You could do some of this programmatically on the fly, but that gets more complicated.
Correct answer by Jagra on February 18, 2021
I think @Jagra has the right idea using PlotGrid. You can do it manually using Grid
or GraphicsGrid
as well, but you end up having to tweak quite a few parameters. If you want to get them to share an x-axis, you can change Jagra's answer like this:
pg = ResourceFunction["PlotGrid"];
data = Table[{x, i PDF[NormalDistribution[], x]}, {i, 3}, {x, -5, 5, 0.1}];
decon = ListLinePlot[#, Axes -> False, Frame -> True] & /@ data;
pg[Transpose[{decon}]]
If you have all of your graphs stored in decon
and it's a 1-D list, you should be able to do the same thing:
pg[Transpose[{decon}]]
EDIT:
It looks like the sizing on your graphs is off. Maybe something like
pg[
Transpose[{decon}],
FrameLabel -> {"x-axis", "y-axis"}
ImageSize -> 500
]
will help? It's hard to say for certain without being able to try your code exactly. My decon
is also generated in a "certain way", so I think they should be fairly similar in theory. If you just call decon
by itself with my code, you'll see that there are three distinct plots.
You may also need to change some options in your plots when you generate decon
such as the label size and things like that. It's also possible to post-process decon
using functions that go through the code contained in decon
and replacing elements, but I'm not very good at that and there's no example code here to really test it on.
Answered by MassDefect on February 18, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP