1

I hope, this question has not been asked on the site before. I recently did the following codes to make two plots separeately. I am thnking of if we could make to plots next to each other while they are being executed? I found this link through the site but, it is related to the case of images not fresh plots.

\documentclass{standalone}‎ 
‎\usepackage{pgfplots}‎
‎\usepgfplotslibrary{fillbetween}‎
‎\pgfplotsset{width=7cm,compat=1.15‎,
‎every axis legend/.append style={at={(0.5,-0.1)},anchor=north‎ ,‎draw=none}}‎
‎\begin{document}‎
‎\begin{tikzpicture}‎
‎\def\verticalbar{2}‎
‎\begin{axis}[domain=-0.5:4.5‎,
‎grid=major‎,
‎legend columns=4‎,
‎samples=25‎,
‎smooth‎,
‎width=7cm‎, ‎height=7cm‎, 
‎axis lines = middle‎, 
‎xlabel = $x$‎, ‎ylabel = {$y$}‎, 
‎xtick={-2,...,8}];‎
‎\addplot [name path=A‎, ‎thick‎, ‎blue,dashed,domain=0:4.5] {4*x-x^2};‎
‎\addlegendentry{$f=4x-x^2$}‎
‎\addplot [name path=B,ultra thick‎, ‎red] {7-x};‎
‎\addlegendentry{$g=7-x$}‎
‎\draw [name path=C‎, ‎dotted‎, ‎thick] (1,0)‎ -- ‎(1,6);‎
‎\draw [name path=D‎, ‎dashed‎, ‎thick] (4,0)‎ -- ‎(4,4);‎
‎\addplot [gray!40] fill between‎ [
‎of=A and B‎, ‎soft clip={domain=1:4},];‎
‎\end{axis}‎
‎\end{tikzpicture}‎
‎\end{document}‎

I mean our output being as follows:

enter image description here

Mikasa
  • 589
  • You could use a groupplot, see for example https://tex.stackexchange.com/questions/349599/two-barcharts-next-to-each-other-with-different-widths-and-same-height/349605#349605 Or you can put multiple axis environments in the same tikzpicture, and position the second one with the at key, see for example https://tex.stackexchange.com/questions/289079/2x2-array-of-pgf-plots/289087#289087 – Torbjørn T. Oct 21 '17 at 16:21
  • You could use the subfigureenvironmet from the package subcaption. – kmbkrkn Oct 21 '17 at 17:46
  • Thanks both of you for every second. Let me try your words. – Mikasa Oct 21 '17 at 17:52

0 Answers0