# How do I make multiple figures in PGFPlotsX and add a table?

**URL:** https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904
**Category:** New to Julia
**Tags:** pgfplotsx
**Created:** [September 19, 2020, 9:50am UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904 "2020-09-19T09:50:28Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [September 19, 2020, 9:50am UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904/1 "2020-09-19T09:50:28Z")

</div>

Hello!

If I wanted to construct something like this:

> <https://tex.stackexchange.com/questions/36442/aligning-subplots-in-a-pgfplots-figure>

![image](https://global.discourse-cdn.com/julialang/original/3X/a/b/abee92359f6f768437678ac1a6686c2ad6e7ed87.png)

As far as for the code I see he is using multiple “\begin{axis}”, but I don’t know if that is possible in PGFPlotsX. I had a look at the gallery here:

[https://kristofferc.github.io/PGFPlotsX.jl/stable/examples/gallery.html](https://kristofferc.github.io/PGFPlotsX.jl/stable/examples/gallery.html)

I saw the group plot example, but does not seem exactly be what I want.

Kind regards

EDIT: Renamed post to better reflect what I needed

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [September 19, 2020, 10:34am UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904/2 "2020-09-19T10:34:20Z")

</div>

Nevermind, I got it, it was actually the group plot example, one just has to change seperation variables etc.

![image](https://global.discourse-cdn.com/julialang/original/3X/a/a/aa523eb1f95f47d342efff5e1b5fec04a4a2aecc.png)

Leaving it up here, if someone struggles like I did

Kind regards

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [September 19, 2020, 1:49pm UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904/3 "2020-09-19T13:49:42Z")

</div>

You can find the docs for `GroupPlot` here:

[https://kristofferc.github.io/PGFPlotsX.jl/dev/man/axislike.html#GroupPlot](https://kristofferc.github.io/PGFPlotsX.jl/dev/man/axislike.html#GroupPlot)

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [September 19, 2020, 2:58pm UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904/4 "2020-09-19T14:58:48Z")

</div>

Thanks, marked yours as solution since it has a link to more documentation!

I really like using it, so far I got this:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/7/67ef02071bde474055772a677f79c2a7c48e6cc3.png)

Now I am trying to figure out how I put a table / tabular in the upper right corner - will probably open a new question in a while, if I don’t manage to figure it out my self

Kind regards

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [September 19, 2020, 3:27pm UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904/5 "2020-09-19T15:27:16Z")

</div>

You may be interested in

[https://github.com/tpapp/LaTeXTabulars.jl](https://github.com/tpapp/LaTeXTabulars.jl)

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [September 19, 2020, 3:50pm UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904/6 "2020-09-19T15:50:09Z")

</div>

Thanks! My struggle right now is that I managed to add it using the raw option in the package:

![image](https://global.discourse-cdn.com/julialang/original/3X/4/7/47e38e6ab60c4c4dd489a3f17fd581fe8399d755.png)

But I cannot figure out how to wrap my table in an axis object… Currently I am making this table as:

```julia
[raw"
                    \pgfplotstabletypeset[
                	col sep=&,	% specify the column separation character
                	row sep=\\,	% specify the row separation character
                	columns/E/.style={string type} % specify the type of data in the designated column
                    ]{
                    	A & B & C & D & E \\
                    	1 & 10 & 0.1 & 1000 & 2011-01-01 \\
                    	2 & 20 & 0.2 & 2000 & 2012-02-02 \\
                    	3 & 30 & 0.3 & 3000 & 2013-03-03 \\
                    	4 & 40 & 0.4 & 4000 & 2014-04-04 \\
                    	5 & 50 & 0.5 & 5000 & 2015-05-05 \\
                    }
            "
        ]

```

Will keep digging

Kind regards

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [September 19, 2020, 5:01pm UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904/7 "2020-09-19T17:01:25Z")

</div>

A good way of debugging is to look at the latex that is generated and compare it to the one you want.

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [September 19, 2020, 5:13pm UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904/8 "2020-09-19T17:13:54Z")

</div>

Thanks for the tip! I got it up and running inside TexStudio, will try to se if I can manage to position my table inside the axis element. Currently the generated LaTeX code and result is:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/8/c81bd4dab8bfe8533c71b048e28dec312c975bc1.png)

If I remove the table:

![image](https://global.discourse-cdn.com/julialang/original/3X/5/5/553e9c82437ebcdf709e2095fb5a24fefc877389.png)

So I think I am on the right track, just have a hard time finding out how to position it correctly

Kind regards

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [September 19, 2020, 6:01pm UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904/9 "2020-09-19T18:01:43Z")

</div>

Here is my LaTex code for a MWE:

```julia
\RequirePackage{luatex85}
\documentclass[tikz]{standalone}
% Default preamble
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{groupplots}
\usepgfplotslibrary{polar}
\usepgfplotslibrary{smithchart}
\usepgfplotslibrary{statistics}
\usepgfplotslibrary{dateplot}
% Custom preamble from global variable:
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[group style={group size={2 by 2}}, height={4cm}, width={4cm}]
    \nextgroupplot[title={1}]
    \addplot+
        coordinates {
            (0,0)
            (1,1)
            (2,2)
        }
        ;
    \nextgroupplot[title={2}]
                        \pgfplotstabletypeset[
                    	col sep=&,	% specify the column separation character
                    	row sep=\\,	% specify the row separation character
                    	columns/E/.style={string type} % specify the type of data in the designated column
                        ]{
                        	A & B & C & D & E \\
                        	1 & 10 & 0.1 & 1000 & 2011-01-01 \\
                        	2 & 20 & 0.2 & 2000 & 2012-02-02 \\
                        	3 & 30 & 0.3 & 3000 & 2013-03-03 \\
                        	4 & 40 & 0.4 & 4000 & 2014-04-04 \\
                        	5 & 50 & 0.5 & 5000 & 2015-05-05 \\
                        }
            
    \nextgroupplot[title={3}]
    \addplot+
        coordinates {
            (0,2)
            (1,1)
            (2,1)
        }
        ;
    \nextgroupplot[title={4}]
    \addplot+
        coordinates {
            (0,2)
            (1,1)
            (1,0)
        }
        ;
\end{groupplot}
\end{tikzpicture}
\end{document}

```

This produces:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/4/7444f1b59316e5e2046c117d018d8e13cc069979.png)

If I out-comment the table generation lines:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/9/b92a178b7d94987403692c306802760dedd8be9b.png)

Basically I want my table to take the place of the empty axis, “2”.

So I am still stuck - if anyone could get it to work from LaTeX I would be happy to hear how. I have tried the commands / googling what I know, but have not been able to do it. The MWE is a slightly modified version of:

[https://kristofferc.github.io/PGFPlotsX.jl/stable/examples/axislike.html](https://kristofferc.github.io/PGFPlotsX.jl/stable/examples/axislike.html)

Kind regards

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [September 19, 2020, 7:56pm UTC](https://discourse.julialang.org/t/how-do-i-make-multiple-figures-in-pgfplotsx-and-add-a-table/46904/10 "2020-09-19T19:56:41Z")

</div>

3-4 hours later I got it to work

![image](https://global.discourse-cdn.com/julialang/original/3X/2/e/2e3b6be3662a37dee33cfef6a4ec189ef0a664f9.png)

The trick is to add an empty invisble plot at the location you want your table and then by using:

```julia
tp = @pgf TikzPicture()
...
push!(tp,p)
push!(tp,q)
display(tp)

```

Where p is your GroupPlot and q is the code you are using (based on PGFPlotsTables in my case) in a raw string format
