• pgfplots: 3D Line Plot with Multiple x Axes
    by Dr. Manuel Kuehner on December 17, 2025 at 9:25 am

    Happy Xmas all together. This question is about pgfplots, specifically about plotting line plots ins 3D. Ideally, I woudl have three x axes labelled x_1, x_2 and x_3, one y axis and one z axis (called F for force). I managned to ge the belwo MWE but from there, I am stuck (did not try ChatGPT yet!). I attached two hand drawings to show the desired outcome. It is ok to fake the three x axes as long there is a easy to understand logic / syntax. Remark: In my real world example, the y axis is reversed but I did not want to overcomplicate the question. (typo: y = -15 should say y = +15 and vice versa) \documentclass{article} \usepackage{pgfplots} \pgfplotsset{ width = \textwidth, compat = 1.18, } \begin{document} \begin{tikzpicture} \begin{axis}[ view = {60}{30}, title = {MWE}, xlabel = {$x$}, ylabel = {$y$}, zlabel = {$F$}, xmin = -30, xmax = 30, ymin = -30, ymax = 30, zmin = -100, % F zmax = 100, grid = major, axis lines = center, ] % Plots \addplot3 [ red, domain = -30:30, % for x I assume samples = 100, samples y = 1, % not sure what this does ](5,x,x^2); \end{axis} \end{tikzpicture} \end{document}

  • How can I code confidence intervals (linear regression) from Jamovi into latex
    by Paulina Puczek on December 16, 2025 at 1:44 pm

    That is my plot from jamovi: and here it is in LaTeX: I want to add those confidence intervals to LaTeX. How do I do it? Here is code: \begin{figure}[H] \noindent {\textbf{Rysunek 6} \\ \textit{Regresja liniowa}} \\ \newline \begin{center} \begin{tikzpicture} \begin{axis}[ width=0.6\textwidth, height=0.5\textwidth, xlabel={Narcyzm grupowy}, ylabel={Religijność indywidualna}, axis x line=bottom, axis y line=left, xmin=-2, xmax=4, ymin=1.5, ymax=6, xtick={-1,0,1,2,3}, ytick={2,3,4,5}, tick label style={font=\small}, label style={font=\small}, legend style={font=\small,draw=none, at={(0.88,0.16)}, anchor=south}, every axis plot/.append style={thick}, ] % Linia: brak autoafirmacji (grupa = 0) \addplot[ blue, ] table { x y -1.5 2.1215 -1 2.385 0 2.912 1 3.439 2 3.966 3 4.493 3.5 4.7565 }; \addlegendentry{kontrolna} % Linia: autoafirmacja (grupa = 1) \addplot[ red, ] table { x y -1.5 1.655 -1 2.017 0 2.741 1 3.465 2 4.189 3 4.913 3.5 5.275 }; \addlegendentry{eksperymentalna} \end{axis} \end{tikzpicture} \end{center} \begin{tablenotes} \small \item {\textit{Adnotacja:} Interakcja (Autoafirmacja × Narcyzm grupowy) dla zmiennej zależnej (Religijność indywidualna).} \end{tablenotes} \end{figure}

  • My y-axis shows numbers like 1, but I want it to display 1.00 (two decimal places) [duplicate]
    by Paulina Puczek on December 15, 2025 at 11:28 am

    \documentclass[a4paper, 12pt, floatsintext]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{polski} \usepackage{float} \usepackage{caption} \usepackage{tikz} \usepackage{newtxtext,newtxmath} % Times New Roman dla tekstu i matematyki \usepackage{csquotes} %quotes \usepackage{tocloft} \usepackage{graphicx} \usepackage[labelsep=newline,labelfont=bf]{caption} \usepackage{times} \usepackage[margin=2.5cm]{geometry} % naglowki czcionka \usepackage{titlesec} \titleformat{\section} {\normalfont\bfseries\fontsize{12}{14}\selectfont\centering} {\thesection}{1em}{} \titleformat{\subsection}{\normalfont\bfseries\fontsize{12}{14}\selectfont}{\thesubsection}{1em}{} \titleformat{\subsubsection}{\normalfont\bfseries\fontsize{12}{14}\selectfont}{\thesubsubsection}{1em}{} \makeatletter \renewcommand{\fnum@table}{\textbf{\tablename~\thetable}} \makeatother \usepackage{apacite} \usepackage{natbib} \usepackage{hyperref} %wyrownuje \PassOptionsToPackage{hyphens}{url} %wyrównuje url i doi % --- Tutaj możesz dodać polecenia do wyłączenia dzielenia wyrazów --- \pretolerance=10000 \tolerance=10000 \hyphenpenalty=10000 \exhyphenpenalty=10000 \usepackage{setspace} %interlinia \doublespacing \usepackage{indentfirst} % wcięcie także po nagłówku \setlength{\parindent}{1.25cm} % wcięcie = 1 tabulator % Tables, figures, plots \usepackage{threeparttable} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage{float} \usepackage{booktabs} \usepackage{graphicx} \usepackage{amsmath} \usepackage{textcomp} % dodatkowe symbole \pgfplotsset{compat=1.18} %table float \usepackage{tikz} \usepackage{pgfplots} \usepackage{float} % Geometry (optional) \usepackage{geometry} %subsections \setcounter{secnumdepth}{4} \setcounter{tocdepth}{4} \usepackage{titlesec} \titleclass{\subsubsubsection}{straight}[\subsubsection] \newcounter{subsubsubsection}[subsubsection] \renewcommand{\thesubsubsubsection}{\thesubsubsection.\arabic{subsubsubsection}} \titleformat{\subsubsubsection} {\normalfont\normalsize\bfseries} {\thesubsubsubsection}{1em}{} \titlespacing*{\subsubsubsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex} \usepackage{fancyhdr} % numbers top right corner \pagestyle{fancy} \fancyhf{} % clear header and footer \fancyhead[R]{\thepage} % page number on the right in the header \renewcommand{\headrulewidth}{0pt} % removes header line \renewcommand{\footrulewidth}{0pt} % removes footer line \usepackage{xcolor} \definecolor{apaBlue}{HTML}{1F77B4} % stonowany niebieski \definecolor{apaOrange}{HTML}{FF7F0E} % stonowany pomarańczowy % tabele i opisy pod Tabela \usepackage{caption} \captionsetup[table]{ format=plain, labelsep=none, % removes ":" after the label justification=raggedright, % left align singlelinecheck=false % ensures left alignment even for short captions } \makeatletter \renewcommand{\fnum@table}{\textbf{\tablename~\thetable}\\} % bold "Tabela 1" and place caption below \makeatother %kropki w spisie treści \renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} \renewcommand{\cftsubsecleader}{\cftdotfill{\cftdotsep}} \renewcommand{\cftsubsubsecleader}{\cftdotfill{\cftdotsep}} %subsubsection italics \renewcommand{\cftsubsubsecfont}{\itshape} \renewcommand{\cftsubsubsecpagefont}{\normalfont} % bibliografia pl nazwa \AtBeginDocument{\renewcommand{\refname}{Bibliografia}} %%%%%%%%%%%%%%%%%%% \begin{document} **and thats the graph** \begin{figure}[H] \noindent {\textbf{Rysunek 3} \\ \textit{Porównanie średnich marginalnych}} \\ \newline \begin{center} \begin{tikzpicture} \begin{axis}[ width=0.6\textwidth, height=0.5\textwidth, ybar=10pt, bar width=18pt, ylabel={Poczucie winy}, xlabel={Autoafirmacja}, ymin=0.5, ymax=2.0, xtick={1,2}, ytick={0.6,0.8,1,1.2,1.4,1.6,1.8}, xticklabels={Kontrolna, Eksperymentalna}, axis x line=bottom, axis y line=left, % x axis line style={->}, % y axis line style={->}, columns=-1, every axis plot/.append style={thick, draw=none}, tick style={black}, tick label style={font=\small}, label style={font=\small}, enlarge x limits=0.6, nodes near coords, every node near coord/.append style={font=\fontsize{9}{7}\selectfont, color=darkgray, yshift=24pt}, legend style={font=\small,draw=none, at={(1.1,0.16)}, anchor=south}, every axis plot/.append style={thick}, ] % --- Niewierzący --- \addplot+[error bars/.cd, y dir=both, y explicit, fill=gray!40] coordinates { (1,1.074) += (0,0.161) -= (0,0.161) % Kontrolna (2,0.995) += (0,0.153) -= (0,0.153) % Afirmacja }; % --- Wierzący --- \addplot+[error bars/.cd, y dir=both, y explicit, fill=black!60] coordinates { (1,1.248) += (0,0.204) -= (0,0.204) % Kontrolna (2,1.611) += (0,0.200) -= (0,0.200) % Afirmacja }; \legend{Niewierzący, Wierzący} \end{axis} \end{tikzpicture} \end{center} \begin{tablenotes} \small \item \textit{Adnotacja}: Rysunek przedstawia średnie marginalne dla zmiennej zależnej (Poczucie winy) i interakcji zmiennych niezależnych (Wiara × Autoafirmacja). \end{tablenotes} \end{figure}

  • Graphing the function y=x^2sin(1/x)
    by azetina on December 13, 2025 at 6:50 pm

    Consider the following MWE: \documentclass{article} \usepackage{amsmath} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ axis equal, axis lines = middle, xlabel = $x$, ylabel = $y$, xmin = -0.4, xmax = 0.4, ymin = -0.4, ymax = 0.4, grid = both, grid style = {line width=.1pt, draw=gray!10}, major grid style = {line width=.2pt, draw=gray!50}, samples = 200, legend pos = north west, width = 10cm, height = 8cm ] % Plot the curve \addplot[domain=-0.4:0.4, thick, blue] {x^2*sin(1/x)}; \addlegendentry{$y = x^2\sin(1/x)$} % Tangent line at (1, -2) \addplot[domain=-0.5:0.5, thick, red] {x^2}; \addplot[domain=-0.5:0.5, thick, red] {-x^2}; \addlegendentry{$y=\pm x^2$} \end{axis} \end{tikzpicture} \end{document} Currently, I am getting: But I would like the curve to show like in the following image: What am I missing?

  • Read and plot dates from .csv using pgfplots
    by Daniel Minutillo on December 11, 2025 at 11:48 am

    I have been trying for hours (with the help of ChatGPT) to read and plot a basic data series from a .csv using pgf plots. My csv file looks like this: Date,Total 1978-02,61.24904688 1978-03,60.9695051 1978-04,61.16856681 1978-05,61.08504061 1978-06,61.08034637 1978-07,60.92327154 The best I've managed so far is as follows: \documentclass[tikz,border=5pt]{standalone} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ title={\textbf{Participation Rates}}, height=9cm, width=12cm, ylabel={Percent}, ymin=40, ymax=80, xmin=0, xmax=664, xtick={23, 143,263,383,503, 623}, xticklabels={1980,1990,2000,2010,2020}, tick align=inside, axis lines=box ] \addplot+[no marks, very thick, color=yellow] table[x expr=\coordindex, y=Total, col sep=comma]{participation.csv}; \end{axis} \end{tikzpicture} \end{document} This is not ideal because I have to hardcode the intervals in the axis tickmarks, making it too inflexible to update with new / alternative data. I've tried to include a plot like: table[x=Date, y=Total, col sep=comma]{participationALT.csv}; But I get an error message: ! Package PGF Math Error: Could not parse input '1978-02' as a floating point number, sorry. The unreadable part was near '-02'.. I've tried messing around with different date formats in my .csv but nothing is working for me so far. Please help!

  • PGFPlots filled polygons with colormap
    by John on December 10, 2025 at 5:30 pm

    I want to plot a bunch of polygons and fill each of them with color from colormap. I am trying the following unsuccessfully: \documentclass[tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} % or "newest" if your TeX supports it \usepgfplotslibrary{colormaps} \begin{document} \begin{tikzpicture} \begin{axis}[ colormap/viridis, colorbar, colorbar style={title={$v$}}, point meta min=0, point meta max=1, ] \addplot[draw=none, fill=mapped color, point meta=2.812245e-02] table [col sep=comma, x index=0, y index=1] {1.csv} -- cycle; \addplot[draw=none, fill=mapped color, point meta=8.440967e-01] table [col sep=comma, x index=0, y index=1] {2.csv} -- cycle; \end{axis} \end{tikzpicture} \end{document} since all of them come out as black polygons (with a viridis colorbar on the side). How do I solve this?

  • Single point in a figure on beamer
    by Patricio on November 28, 2025 at 4:00 pm

    I'm trying to build a figure on beamer that has a single point on it. I've tried what I'd usually have done in other settings (article, book), but I'm still getting an error. In particular, I get ! Package pgfplots Error: Could not read table file '" x y label\\ 3 12 $x$\\ " ' in 'search path=.'. In case you intended to provide inline data: maybe TeX sc rewed up your end-of-lines? Try `row sep=crcr' and terminate your lines with `\ \' (refer to the pgfplotstable manual for details). See the pgfplots package documentation for explanation. However, as it is apparent from my code, I'm already using row sep=crcr My code is \documentclass{beamer} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \begin{frame} \begin{tikzpicture} \begin{axis}[ axis x line=bottom, axis y line=left, axis equal image, axis on top, ticks = none, xmin=0,xmax=20, ymin=0,ymax=20] \addplot+[only marks,row sep=crcr,mark=*,black,mark options={fill=black},nodes near coords,nodes near coords align=right,point meta=explicit symbolic ] table[meta=label]{ x y label\\ 3 12 $x$\\ }; \end{axis} \end{tikzpicture} \end{frame} \end{document}

  • Thicker axis in PGFplot
    by mf67 on November 26, 2025 at 11:46 am

    Is there a better method to have the x=0 and y=0 axes thicker? I made a basic approach by adding lines, but is there a better method? \documentclass{book} \usepackage{pgfplots} \pgfplotsset{compat=1.15} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=0.8] \begin{axis}[ xmin=-2, xmax=6, ymin=-1.5, ymax=10, xtick={0,2,4}, ytick={0,2,4,6,8}, xmajorgrids=true, ymajorgrids=true, ytick style={draw=none}, xtick style={draw=none}, xlabel=$x$, ylabel=$y$, height=5cm, axis equal image ] \addplot [domain=-2:6, samples=100, color=blue!50, line width=1pt]{pow(x-2,2)}; \addplot [domain=-2:6, color=red!50, line width=1pt]{4}; \draw[line width=.5pt] ({axis cs:0,-2}) -- ({axis cs:0,10}); \draw[line width=.5pt] ({axis cs:-10,0}) -- ({axis cs:10,0}); \draw[line width=.5pt, green] (-2,0)--(0,0); \draw[green,fill=white] (0,0) circle(2pt); \draw[line width=.5pt, green] (4,0)--(6,0); \draw[green,fill=white] (4,0) circle(2pt); \end{axis} \end{tikzpicture} \end{document} This is not the same as pgfplots: how to make the axis thick? as that 'thicker' command results in thicker frame, not axes. N.B. I don't want thicker arrow axes, I want thicker 'axes lines' in a framed plot. They do not seem to want to 'co-exist'.

  • Inaccurate TikZ/PGF plot
    by Dominique on November 24, 2025 at 6:31 pm

    I'm using the following code to produce a plot: \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ width = 15cm, xtick = {0, 1, 2, 3, 4, 5}, ] \addplot[black, thick, smooth, domain=0:5] {exp(-100 * \x) + sin(\x)}; \addplot[blue, thick, smooth] table {stiff.dat}; \end{axis} \end{tikzpicture} \end{document} It produces the following plot: Here, the blue curve plots data points generated with Matlab for the same function. The blue curve is correct, but the black one is not. It seems TikZ is not able to plot the function accurately. I've read on this forum about this issue and I tried a few things: \ustikzlibrary{fpu}: did not help; that may be because the PFU is limited to 4-5 digits \usepackage{xfp}: I could not get this to work and kept getting an error with \fpeval \usepackage{expl3}: same. I must be doing something wrong. What is the correct incantation here? I would rather not resort to compiling with Lua because my document is part of series that all compile fine with PDFLaTeX. Thank you in advance!

  • help with 3D Surface plot TikZ
    by Mark Roelands on November 16, 2025 at 9:20 pm

    Can someone please help with coding the surface plot for $\sqrt{(x - 1)^2 + y^2} + \sqrt{(x + 1)^2 + y^2} - 4 = -|z|$ in TikZ for my article in LateX? I have been trying, but can't seem to manage it. This is what I have so far, it only plots one half of the surface on a square but not within the disk: \begin{tikzpicture} \begin{axis}[ hide axis, colormap/cool, ] \addplot3[ mesh, samples=50, domain=-2:2, ] {deg(sqrt((x - 1)^2 + y^2) + sqrt((x + 1)^2 +y^2) - 4)}; \end{axis} \end{tikzpicture}

  • Error linked to active characters?
    by Bibi on November 13, 2025 at 5:46 pm

    This MWE gives an error that disappears if line #3 or line #4 are commented. I would say that this has probably something to do with active characters, but I am not able to understand what goes wrong here. Any help? \documentclass[9pt, professionalfont]{beamer} \usepackage{pgfplots} \usepackage[french]{babel} % No error if this line (or the next one) is commented \usetikzlibrary{babel} \begin{document} \begin{frame} \begin{overlayarea}{\textwidth}{5cm} \only<1>{ \begin{center} \begin{tikzpicture} \begin{axis} \addplot {x^2+4}; \end{axis} \end{tikzpicture} \end{center} } \end{overlayarea} \end{frame} \end{document}

  • \tikzmath defined functions sometimes won't parse in \addplot, producing spurious errors
    by Francis Cook on November 13, 2025 at 12:38 pm

    This is my first post so the graph may not appear and/or the format may look weird. Apologies if that is so. The graph is produced when the line \addplot[red, thick] {myexp(x,4)}; is commented out When included, numerous errors result, seemingly spurious because it is not being parsed as expected, for example "! Illegal unit of measure (pt inserted)." Unfortunately, I cannot see my mistake. I have tried everything I can think of, including spaces before and/or after pretty much every reference and even trying to use "declare function" (but I couldn't make that work the with complex, iterative logic). I am puzzled by the fact that a simple, two argument function (myfunc) can be called successfully, one with more complex logic (expterm) can be called successfully, but a complex one, with a loop and calls (myexp) fails. Any help/suggestions gratefully received. I am hoping to fix this with \tikzmath rather than use the equivalent pgfplots function definitions etc The code is as follows \documentclass{article} \usepackage{pgfplots} \usetikzlibrary{math} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} % Define the function using tikzmath - scope is within the tikzpicture % note that the \tikzmath block is sensitive to blank lines % so don't leave any lines blank % inclde non math lines like drawing commands within double curly braces {{ }} \tikzmath{ function myfunc(\x,\a) { return sin(\x r) + \a*\x; }; function expterm(\x,\n) { if \n == 0 then { return 1; } else { if \n == 1 then { return \x; } else { return \x ^ \n / factorial(\n); }; }; }; function myexp(\x,\n) { \s=0; for \i in {0,1,...,\n-1}{ \s=\s+expterm(\x,\i); }; return \s; }; } \begin{axis}[ domain=-2*pi:2*pi, xmin=-2*pi, xmax=2*pi, ymin=-3, ymax=3, restrict y to domain=-3:3, samples=100, axis lines=middle, xtick={ -2*pi, -3*pi/2, -pi, -pi/2, pi/2, pi, 3*pi/2, 2*pi }, xticklabels={ $-2\pi$, $-\frac{3\pi}{2}$, $-\pi$, $-\frac{\pi}{2}$, $\frac{\pi}{2}$, $\pi$, $\frac{3\pi}{2}$, $2\pi$ }, width=14cm, height=14cm, xlabel=$x$, ylabel={$y = f(x)$}, title={Function defined in \texttt{\textbackslash tikzmath}} ] % Use the tikzmath function in an addplot \addplot[blue, thick] {myfunc(x,0.3)}; \addplot[green, thick] {expterm(x,3)}; % \addplot[red, thick] {myexp(x,4)}; \end{axis} \end{tikzpicture} \end{document}

  • Why does PGFPlots separate the axes of my log-log graph?
    by Rain on November 12, 2025 at 6:53 pm

    I'm trying to make a log-log graph. Semi-log graphs and linear graphs work just fine, but for some reason when I try to make a log-log graph PGFPlots doesn't draw the horiziontal axis or the curve. MWE: \documentclass[11pt,a4paper]{article} \usepackage{pgfplots} \pgfplotsset{compat=1.9} \begin{document} \begin{tikzpicture} \begin{loglogaxis}[ xmin=10, xmax=40, axis x line=middle, xlabel=$x$, ymin=10, ymax=50, axis y line=center, ylabel=$y$, disabledatascaling ] \addplot[smooth,thick,blue,domain=10:40,samples=51]coordinates{ (10,10) (20,30) (30,20) (40,42) }; \end{loglogaxis} \end{tikzpicture} \end{document} Result: Scale has nothing to do with it. I get the same problem if I set the axis ranges to, say, (1e8,1e12). Thanks in advance for any help.

  • Aligning arrows along a path at fixed steps on a rectangular grid
    by PatrickT on November 11, 2025 at 5:42 pm

    The objective is to have arrows along a path for every 1-unit step we take horizontally or vertically. The arrows would be aligned midway between major grid tick marks, e.g. midway along (0,0)--(0,1). To give context, these arrows could be used to show east-west and north-west movement along a rectangular grid. I have managed to handle the case where the x and y units are the same. Below I have tweaked the parameters to have the blue arrows aligned at the midpoint (grid minor line colored in cyan). But I failed with the red arrows. The problem is that the x-scale and y-scale are quite different. If the step is tweaked to match horizontal distances (parallel to the x-axis), then it will not match the vertical distances. How to fix this? To clarify, if I give a path like (0,0)--(10,0), I would like an arrow midway along (0,0)--(1,0), then midway along (1,0)--(2,0), and so on. Otherwise I would just use something like [midway](0,0)--(10,0) or [pos=0.5](0,0)--(10,0). In my code I have to tweak the "starting value" as well as the "step". It would obviously be much nicer to have a solution where I could set a starting value at 0.5 (meaning at the midway point between two major grid tick lines) and a step equal to 1 (meaning moving by 1 unit of image scale --- not units of the axis --- along both x and y directions). \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{calc} % Required for coordinate calculations \usetikzlibrary{decorations.markings} % Required for decorations along path % Define a TikZ style for arrows on path: color as optional argument % \usetikzlibrary{decorations.markings, arrows.meta} \tikzset{ arrows along path/.style args={#1/#2/#3}{% >=latex, decoration={ markings, mark=between positions #1 and #2 step #3 with { \arrow{latex} } }, postaction={decorate} }, arrows along path/.default={0/1/0.5} } % x has range 5 % y has range 3000 % 3000/5 = 600 % 5/3000 = 0.00166666666 \begin{document} \begin{tikzpicture} \begin{axis}[ x = 2cm, y = 0.0033cm,% tweaked to match y/x=5/3000 ratio xmin=0, xmax=5, ymin=500, ymax=3500, xtick = {0,1,...,5}, ytick = {500,1000,...,3500}, tick align=outside, minor tick num=1, minor tick length=4pt, minor tick style={color=cyan,thick}, minor grid style={color=cyan,thick}, grid = both, clip = false, ] \coordinate (A) at (0,2000); \coordinate (B) at (5,2000); \coordinate (C) at (0,1000); \coordinate (D) at (1,1000); \coordinate (E) at (1,3000); \coordinate (F) at (4,3000); \coordinate (G) at (4,1000); \coordinate (H) at (5,1000); % Blue line \draw [blue, thick, arrows along path={0.118/1/0.20}] (A) -- (B); % Red line \draw [red, thick, arrows along path={0.051/1/0.079}] (C) -- (D) -- (E) -- (F) -- (G) -- (H); \end{axis} \end{tikzpicture} \end{document} Second implementation, also fails to get the correct output: \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{calc} % Required for coordinate calculations \usetikzlibrary{decorations.markings} % Required for decorations along path % Define a TikZ style for arrows on path: color as optional argument % \usetikzlibrary{decorations.markings, arrows.meta} \tikzset{ arrows along path/.style args={#1/#2/#3}{% >=latex, decoration={ markings, mark=between positions #1 and #2 step #3 with { \arrow{latex} } }, postaction={decorate} }, arrows along path/.default={0/1/0.5} } \begin{document} \begin{tikzpicture} \begin{axis}[ x=2cm, y=0.0033cm, xmin=0, xmax=5, ymin=500, ymax=3500, xtick = {0,1,...,5}, ytick = {500,1000,...,3500}, tick align=outside, minor tick num=1, minor tick length=4pt, minor tick style={color=cyan,thick}, minor grid style={color=cyan,thick}, grid = both, clip = false, ] \coordinate (A) at (0,2000); \coordinate (B) at (5,2000); \coordinate (C) at (0,1000); \coordinate (D) at (1,1000); \coordinate (E) at (1,3000); \coordinate (F) at (4,3000); \coordinate (G) at (4,1000); \coordinate (H) at (5,1000); % Blue line \draw [blue, thick, arrows along path={0.12/1/0.20}] (A) -- (B); % Red line \pgfplotsextra{ \foreach \P/\Q in {C/D, D/E, E/F, F/G, G/H}{ \draw [red, thick, arrows along path={0.6/1/0.40}] (\P) -- (\Q); } } \end{axis} \end{tikzpicture} \end{document} A variant with a node and a dot, that sort of look like the ideal implementation for its simplicity, but fails just the same. \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{calc} % Required for coordinate calculations \usetikzlibrary{decorations.markings} % Required for decorations along path % set up all axes \pgfplotsset{% every axis/.append style={% axis styles %ticks = none, grid = both, clip = false,% remove clip }% }% % Define a TikZ style for arrows \tikzset{ marks along path/.style args={#1/#2/#3/#4}{% decoration={ markings, mark=between positions #1 and #2 step #3 with { \node[#4] at (0,0) {}; } }, postaction={decorate} }, marks along path/.default={0/1/0.5/shape=circle,fill=black,draw=black,inner sep=0pt,minimum size=4mm,line width=2pt} } \begin{document} \begin{tikzpicture} \begin{axis}[ x = 2cm, y = 0.0033cm,% tweaked to match y/x=5/3000 ratio xmin=0, xmax=5, ymin=500, ymax=3500, xtick = {0,1,...,5}, ytick = {500,1000,...,3500}, tick align=outside, minor tick num=1, minor tick length=4pt, minor tick style={color=cyan,thick}, minor grid style={color=cyan,thick}, grid = both, clip = false, ] \coordinate (A) at (0,2000); \coordinate (B) at (5,2000); \coordinate (C) at (0,1000); \coordinate (D) at (1,1000); \coordinate (E) at (1,3000); \coordinate (F) at (4,3000); \coordinate (G) at (4,1000); \coordinate (H) at (5,1000); % Blue line \draw[blue, line width=2pt, marks along path={0/1/0.5/shape=circle,fill=blue,draw=black}] (A) -- (B); \draw[red, line width=2pt, marks along path={0/1/0.5/shape=circle,fill=red,draw=black}] (C) -- (D) -- (E) -- (F) -- (G) -- (H); \end{axis} \end{tikzpicture} \end{document}

  • Plotting quasi-3D figure with axial filled planes
    by katang on November 11, 2025 at 4:10 pm

    I want to make a quasi-3D figure from three variables. They pair-wise form a two-dimensional figure. I want to emphasize that the green plot is in the green plane, etc. I have two issues 1./ The red and green planes are OK, but the blue plane is squeezed to a line 2./ The opacity does not work as I expected What did I do wrong? (3./ A better idea to illustrate what I want?) \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \usetikzlibrary{backgrounds} \definecolor{webblue}{rgb}{0,0,.8} \definecolor{webgreen}{rgb}{0, 0.5, 0} % less intense green \definecolor{webred}{rgb}{0.5, 0, 0} % less intense red \begin{filecontents*}{data.csv} a,b,c,d,e,f,g,h,i,j,k 0.001,0.180,0.000,0.000,0.000,179.563,1,0.000, 0.003,0.528,0.000,0.000,2.565,174.248,1,0.147, 0.007,1.184,0.000,0.000,7.544,163.879,1,0.431, 0.015,2.337,0.000,0.000,16.908,144.160,1,0.967, 0.031,2.613,0.000,0.000,33.384,276.050,1,1.908, 0.033,3.147,0.000,0.000,37.327,267.271,1,2.134, 0.037,4.148,0.000,0.000,44.964,250.157,1,2.570, 0.045,4.547,0.000,0.000,59.258,398.610,1,3.388, 0.047,5.318,0.000,0.000,64.953,385.747,1,3.713, 0.051,6.761,0.000,0.000,75.974,360.676,1,4.343, 0.059,9.266,0.000,0.000,96.584,313.078,1,5.521, 0.067,11.279,0.000,0.000,132.364,251.728,1,7.567, 0.075,11.654,0.000,0.000,161.133,374.187,1,9.211, 0.077,12.374,0.000,0.000,166.479,360.293,1,9.517, 0.081,13.707,0.000,0.000,176.773,333.243,1,10.106, 0.089,15.963,0.000,0.000,195.815,282.019,1,11.194, 0.097,17.718,0.000,0.000,228.046,219.302,1,13.037, 0.113,19.926,0.000,0.000,253.109,138.008,1,14.469, 0.129,20.822,0.000,0.000,284.654,56.022,1,16.273, 0.130,24.281,3.978,3756.321,297.459,3458.862,0,17.005, 0.131,27.647,7.913,3713.080,346.871,3366.209,0,19.829, 0.132,30.923,11.804,3670.273,394.960,3275.313,0,22.579, 0.133,34.109,15.653,3627.897,441.750,3186.147,0,25.253, 0.134,37.207,19.460,3585.946,487.267,3098.679,0,27.855, 0.135,40.220,23.224,3544.416,531.533,3012.883,0,30.386, 0.136,43.149,26.948,3503.303,574.575,2928.729,0,32.847, 0.137,45.995,30.631,3462.604,616.414,2846.190,0,35.238, 0.138,48.760,34.273,3422.313,657.073,2765.240,0,37.563, 0.139,51.446,37.875,3382.428,696.577,2685.851,0,39.821, 0.140,54.054,41.438,3342.943,734.946,2607.997,0,42.014, 0.141,56.586,44.961,3303.855,772.203,2531.652,0,44.144, 0.142,59.043,48.446,3265.160,808.370,2456.790,0,46.212, 0.143,61.426,51.892,3226.854,843.467,2383.387,0,48.218, 0.144,63.737,55.300,3188.933,877.515,2311.418,0,50.165, 0.145,65.978,58.671,3151.394,910.535,2240.858,0,52.052, 0.146,68.150,62.005,3114.232,942.548,2171.684,0,53.882, 0.147,70.254,65.302,3077.444,973.572,2103.872,0,55.656, 0.148,72.291,68.562,3041.026,1003.627,2037.399,0,57.374, 0.149,74.264,71.786,3004.975,1032.733,1972.242,0,59.038, 0.151,78.010,78.128,2933.957,1060.908,1873.050,0,60.649, 0.153,81.510,84.331,2864.363,1114.423,1749.940,0,63.708, 0.155,84.773,90.397,2796.163,1164.422,1631.742,0,66.566, 0.157,87.810,96.328,2729.332,1211.043,1518.289,0,69.231, 0.159,90.628,102.129,2663.840,1254.422,1409.418,0,71.711, 0.161,93.238,107.802,2599.663,1294.691,1304.972,0,74.013, 0.163,95.648,113.348,2536.775,1331.976,1204.798,0,76.145, 0.165,97.865,118.772,2475.149,1366.399,1108.750,0,78.112, 0.167,99.899,124.075,2414.762,1398.078,1016.685,0,79.923, 0.169,101.756,129.261,2355.590,1427.126,928.464,0,81.584, 0.173,104.904,139.287,2240.791,1453.653,787.137,0,83.101, 0.177,107.432,148.871,2130.568,1498.633,631.936,0,85.672, 0.181,109.392,158.029,2024.744,1534.743,490.001,0,87.736, 0.189,111.495,175.141,1825.613,1562.743,262.869,0,89.337, 0.197,111.890,190.756,1642.107,1592.786,49.321,0,91.054, 0.213,107.391,217.966,1317.289,1598.422,-281.134,0,91.376, 0.221,104.509,229.776,1173.854,1534.163,-360.310,0,87.703, 0.229,100.899,240.517,1041.785,1492.985,-451.200,0,85.349, 0.237,96.730,250.275,920.210,1441.419,-521.210,0,82.401, 0.241,94.655,254.812,863.102,1381.853,-518.750,0,78.996, 0.245,92.479,259.131,808.320,1352.210,-543.889,0,77.301, 0.249,90.218,263.244,755.773,1321.130,-565.358,0,75.525, 0.253,87.884,267.158,705.371,1288.824,-583.453,0,73.678, 0.257,85.490,270.882,657.031,1255.484,-598.453,0,71.772, 0.261,83.048,274.423,610.670,1221.286,-610.616,0,69.817, 0.265,80.567,277.789,566.212,1186.394,-620.182,0,67.822, 0.269,78.057,280.987,523.581,1150.955,-627.374,0,65.796, 0.273,75.528,284.025,482.704,1115.105,-632.402,0,63.747, 0.277,72.986,286.908,443.511,1078.968,-635.457,0,61.681, 0.281,70.439,289.644,405.937,1042.656,-636.719,0,59.605, 0.285,67.894,292.238,369.916,1006.272,-636.356,0,57.525, 0.289,65.356,294.697,335.388,969.909,-634.521,0,55.446, 0.293,62.830,297.025,302.292,933.651,-631.359,0,53.374, 0.297,60.322,299.229,270.571,897.573,-627.002,0,51.311, 0.301,57.836,301.314,240.171,861.744,-621.573,0,49.263, 0.305,55.375,303.284,211.040,826.226,-615.186,0,47.233, 0.309,52.943,305.144,183.125,791.072,-607.947,0,45.223, 0.313,50.543,306.899,156.379,756.332,-599.954,0,43.237, 0.317,48.178,308.553,130.754,722.049,-591.295,0,41.277, 0.321,45.850,310.111,106.207,688.261,-582.054,0,39.346, 0.325,43.561,311.576,82.693,655.001,-572.308,0,37.444, 0.329,41.312,312.952,60.171,622.298,-562.127,0,35.575, 0.333,39.106,314.244,38.601,590.176,-551.575,0,33.738, 0.337,36.943,315.454,17.945,558.657,-540.712,0,31.937, 0.341,34.825,316.586,-1.833,527.760,-529.593,0,30.170, 0.345,32.752,317.643,-20.770,497.497,-518.267,0,28.440, 0.349,30.725,318.629,-38.899,467.882,-506.781,0,26.747, 0.353,28.744,319.546,-56.253,438.923,-495.176,0,25.092, 0.361,24.749,321.186,-88.759,410.627,-499.386,0,23.474, 0.369,20.972,322.584,-118.525,353.554,-472.079,0,20.212, 0.377,17.409,323.761,-145.767,299.603,-445.369,0,17.127, 0.379,16.994,323.761,-152.207,248.703,-414.874,1,14.218, 0.381,16.162,323.761,-158.505,242.776,-416.267,1,13.879, 0.385,14.488,323.761,-170.686,230.883,-418.554,1,13.199, 0.393,11.118,323.761,-193.467,206.966,-421.244,1,11.832, 0.401,7.937,323.761,-214.281,158.823,-397.523,1,9.079, 0.409,4.941,323.761,-233.285,113.392,-374.496,1,6.482, 0.417,2.124,323.761,-250.623,70.593,-352.238,1,4.036, 0.425,-0.523,323.761,-266.428,30.337,-330.805,1,1.734, 0.433,-3.005,323.761,-280.823,-7.469,-310.237,1,-0.427, 0.441,-5.329,323.761,-293.922,-42.925,-290.557,1,-2.454, 0.449,-7.503,323.761,-305.828,-76.131,-271.776,1,-4.352, 0.457,-9.535,323.761,-316.637,-107.192,-253.896,1,-6.128, 0.465,-11.430,323.761,-326.438,-136.208,-236.910,1,-7.787, 0.481,-15.123,323.761,-343.332,-163.284,-230.797,1,-9.334, 0.497,-18.249,323.761,-357.086,-216.037,-195.389,1,-12.350, 0.513,-20.889,323.761,-368.187,-260.698,-164.995,1,-14.903, 0.529,-23.112,323.761,-377.048,-298.411,-138.927,1,-17.059, 0.545,-24.977,323.761,-384.017,-330.166,-116.585,1,-18.874, 0.577,-28.284,323.761,-393.420,-356.814,-103.345,1,-20.398, 0.593,-29.254,323.761,-396.315,-404.057,-60.619,1,-23.099, 0.625,-30.933,323.761,-399.392,-417.913,-52.457,1,-23.891, 0.657,-31.917,323.761,-399.750,-441.893,-30.752,1,-25.262, 0.689,-32.445,323.761,-398.191,-455.951,-16.499,1,-26.065, 0.721,-32.668,323.761,-395.292,-463.494,-6.977,1,-26.496, 0.753,-32.685,323.761,-391.462,-466.683,-0.527,1,-26.679, 0.785,-32.560,323.761,-386.996,-466.924,3.892,1,-26.692, 0.817,-32.338,323.761,-382.102,-465.145,6.940,1,-26.591, 0.849,-32.048,323.761,-376.930,-461.972,9.050,1,-26.409, 0.881,-31.712,323.761,-371.585,-457.835,10.506,1,-26.173, 0.913,-31.344,323.761,-366.142,-453.032,11.503,1,-25.898, 0.945,-30.955,323.761,-360.656,-447.774,12.174,1,-25.598, 0.977,-30.551,323.761,-355.164,-442.208,12.611,1,-25.280, 1.009,-30.139,323.761,-349.693,-436.444,12.879,1,-24.950, 1.041,-29.722,323.761,-344.262,-430.556,13.025,1,-24.613, 1.073,-29.304,323.761,-338.882,-424.602,13.082,1,-24.273, 1.105,-28.885,323.761,-333.564,-418.622,13.074,1,-23.931, 1.137,-28.469,323.761,-328.313,-412.645,13.019,1,-23.590, 1.169,-28.055,323.761,-323.133,-406.693,12.930,1,-23.249, 1.201,-27.645,323.761,-318.026,-400.782,12.816,1,-22.911, 1.233,-27.239,323.761,-312.994,-394.924,12.684,1,-22.576, 1.265,-26.838,323.761,-308.037,-389.125,12.539,1,-22.245, 1.297,-26.441,323.761,-303.156,-383.393,12.385,1,-21.917, 1.329,-26.050,323.761,-298.350,-377.731,12.225,1,-21.594, 1.361,-25.664,323.761,-293.618,-372.143,12.061,1,-21.274, 1.393,-25.283,323.761,-288.961,-366.629,11.895,1,-20.959, 1.425,-24.908,323.761,-284.376,-361.191,11.727,1,-20.648, 1.457,-24.538,323.761,-279.864,-355.831,11.559,1,-20.342, 1.489,-24.174,323.761,-275.423,-350.546,11.391,1,-20.040, 1.521,-23.815,323.761,-271.052,-345.339,11.225,1,-19.742, 1.553,-23.461,323.761,-266.750,-340.208,11.059,1,-19.449, 1.585,-23.112,323.761,-262.516,-335.152,10.895,1,-19.160, 1.617,-22.769,323.761,-258.350,-330.171,10.733,1,-18.875, 1.649,-22.430,323.761,-254.249,-325.265,10.573,1,-18.594, 1.681,-22.097,323.761,-250.214,-320.432,10.414,1,-18.318, 1.713,-21.769,323.761,-246.242,-315.671,10.258,1,-18.046, 1.745,-21.445,323.761,-242.334,-310.982,10.103,1,-17.778, 1.777,-21.127,323.761,-238.487,-306.363,9.951,1,-17.514, 1.809,-20.813,323.761,-234.702,-301.814,9.801,1,-17.254, 1.841,-20.504,323.761,-230.977,-297.333,9.653,1,-16.998, 1.873,-20.200,323.761,-227.311,-292.920,9.508,1,-16.745, 1.905,-19.901,323.761,-223.703,-288.574,9.364,1,-16.497, 1.937,-19.605,323.761,-220.152,-284.293,9.223,1,-16.252, 1.969,-19.315,323.761,-216.657,-280.077,9.083,1,-16.011, \end{filecontents*} \pgfplotscreateplotcyclelist{my color list}{ solid, color=webblue, every mark/.append style={solid, fill=webblue}, no marks\\% densely dashdotted, color=webred, every mark/.append style={solid, fill=webred},no marks\\% densely dotted, thick, color=webgreen, every mark/.append style={solid, fill=webgreen}, no marks%mark=triangle* \\% } \begin{document} \begin{tikzpicture} \begin{axis} [ axis lines=center,view={15}{25}, xlabel={$t$}, ylabel=$V_M$,zlabel=$\frac{dV}{dt}$, xtick={1}, ytick=100, y label style={at={(axis description cs:0.25,.5)}, anchor=south}, cycle list name={my color list}, z label style={at={(axis description cs:-0.06,.7)}, anchor=west}, cycle list name={my color list}, ] \addplot3+ table [x=a, y=b, z expr=0,col sep=comma, no marks] {data.csv}; \addplot3+ table [x=a, z=d, y expr=0, col sep=comma] {data.csv}; \addplot3+ table [y=b, z=d, x expr=0, col sep=comma] {data.csv}; \begin{scope}[on background layer] \addplot3 [fill=webgreen!20,opacity=30,draw=none] coordinates {(0,-40,3900)(0,120,3900)} \closedcycle; \addplot3 [fill=webgreen!20,draw=none] coordinates {(0,-40,-1200)(0,120,-1200)} \closedcycle; \addplot3 [fill=red!10,opacity=30,draw=none] coordinates {(0,0,3900)(2,0,3900)} \closedcycle; \addplot3 [fill=red!10,draw=none] coordinates {(0,0,-1200)(2,0,-1200)} \closedcycle; \addplot3 [fill=blue!30,draw=none] coordinates {(2,-40,0)(2,120,0)} \closedcycle; \addplot3 [fill=blue!30,draw=none] coordinates {(1,-40,0)(1,120,0)} \closedcycle; \end{scope} \end{axis} \end{tikzpicture} \end{document}

  • Plot any real sequence of real variables as in Geogebra and Desmos
    by Sebastiano on November 8, 2025 at 11:25 pm

    Several years ago, I created a GeoGebra script to plot any real sequence of real variables. As you can see from the screenshot, there is a command on the left: Sequence({(n, 1/n)}, n, 1, M) which putting every sequence, give me a graph of this. Usually, I use GeoGebra and then quickly export to TikZ with the option Save as. Here an example: \documentclass[10pt]{article} \usepackage{pgfplots} \pgfplotsset{compat=1.15} \usepackage{mathrsfs} \usetikzlibrary{arrows} \pagestyle{empty} \begin{document} \definecolor{qqweqq}{rgb}{0,0.43137254901960786,0} \definecolor{aqaqaq}{rgb}{0.6274509803921569,0.6274509803921569,0.6274509803921569} \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm] \begin{axis}[ x=1cm,y=1cm, axis lines=middle, grid style=dashed, xmin=-0.41753528626111724, xmax=22.657576260984815, ymin=-1.2286763992422356, ymax=7.280825323814707, xtick={0,1,...,22}, ytick={-1.2000000000000002,-1.1,...,7.200000000000001},] \clip(-0.41753528626111724,-1.2286763992422356) rectangle (22.657576260984815,7.280825323814707); \draw[line width=5.2pt,color=aqaqaq] (5.616473767760089,4.363281875909468) -- (10.036993221255479,4.363281875909468); \draw (11.053712695559419,5.777848396105947) node[anchor=north west] {$a_n= \frac{1}{n} \quad \quad n \in [1,14]$}; \begin{scriptsize} \draw [fill=aqaqaq] (7.598085936568367,4.363281875909468) circle (3pt); \draw[color=aqaqaq] (8.158272453519938,5.114770339763847) node {$M = 14$}; \draw [fill=qqweqq] (1,1) circle (1.5pt); \draw [fill=qqweqq] (2,0.5) circle (1.5pt); \draw [fill=qqweqq] (3,0.3333333333333333) circle (1.5pt); \draw [fill=qqweqq] (4,0.25) circle (1.5pt); \draw [fill=qqweqq] (5,0.2) circle (1.5pt); \draw [fill=qqweqq] (6,0.16666666666666666) circle (1.5pt); \draw [fill=qqweqq] (7,0.14285714285714285) circle (1.5pt); \draw [fill=qqweqq] (8,0.125) circle (1.5pt); \draw [fill=qqweqq] (9,0.1111111111111111) circle (1.5pt); \draw [fill=qqweqq] (10,0.1) circle (1.5pt); \draw [fill=qqweqq] (11,0.09090909090909091) circle (1.5pt); \draw [fill=qqweqq] (12,0.08333333333333333) circle (1.5pt); \draw [fill=qqweqq] (13,0.07692307692307693) circle (1.5pt); \draw [fill=qqweqq] (14,0.07142857142857142) circle (1.5pt); \end{scriptsize} \end{axis} \end{tikzpicture} \end{document} With Desmos, for example, there is a page where https://www.desmos.com/calculator/4wwz1emgyd?lang=it I have given an arbitrary sequence a(x)= sin ( (π/2) ⋅ x⁴/(x⁴+1)) it gives a graph. Is it possible to have the same thing of Geogebra and Desmos in TikZ/Metapost/Lua that allow me to plot any sequence directly to save time without to write a long code?

  • Iterated plot with TikZ, PGFPlots and foreach loop
    by Dominique on November 5, 2025 at 4:31 pm

    I'm trying to plot an illustration of the fixed point method in which a function is evaluated repeatedly in a loop. The result should be a staircase or spiral plot on top of the plot of the function itself. I've read here about the use of \edef inside a foreach loop. The following MWE should show what I'm trying to do, but it seems to only perform a single iteration. Notes: the loop variable isn't used inside the loop. perhaps it's an illusion that only single iteration is performed and the real issue is that \xprev and \xnext aren not updated at each pass through the loop. I tried placing the updates inside the \edef, but that gives an undefined control sequence error. I also tried \pgfplotsinvokeforeach instead of \foreach, but only obtained other errors. \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \pgfmathdeclarefunction{g}{1}{\pgfmathparse{#1^2 - 2}} \begin{tikzpicture} \begin{axis} [ xmin = -2.5, xmax = 2.5, ymin = -3, ymax = 3, axis x line = center, axis y line = center, domain=-2.5:2.5, samples=300, ] \addplot[ultra thick] {g(x)}; % graph of g \addplot[thin] {x}; % diagonal \def\xstart{-0.75} \pgfmathsetmacro{\xprev}{\xstart}; \pgfmathsetmacro{\xnext}{g(\xprev)}; \draw[thick, blue] (\xstart, 0) -- (\xstart, \xnext) -- (\xnext, \xnext); \foreach \i in {1, 2, 3}{ \pgfmathsetmacro{\xprev}{\xnext} \pgfmathsetmacro{\xnext}{g(\xprev)} % x <- g(x) \edef\plotoneiter{% \noexpand% \draw[thick, blue] ({\xprev}, {\xprev}) -- ({\xprev}, {\xnext}) -- ({\xnext}, {\xnext}); }\plotoneiter% } \end{axis} \end{tikzpicture} \end{document} Thanks in advance for any hints! EDIT: Here is a quick sketch of what I'm trying to achieve:

  • Problem trying to set color in dynamic in pgfplot [duplicate]
    by Liam Seddio on November 2, 2025 at 6:12 pm

    I'm trying to draw 10 functions of ten different colors (actually starting from red and ending with yellow) inside a tikzpicture environment. Problem is that the code reads only the first color (red) and then plot all 10 functions in green Here's the code: \documentclass{amsart} \usepackage[english]{babel} \usepackage{amsmath} \usepackage{hyperref} \usepackage[a4paper, margin=2.5cm]{geometry} \usepackage{pgfplots} \usepackage{xcolor} \pgfplotsset{compat=1.18} \usepackage{mdframed} \usepackage{subcaption} \begin{document} \begin{figure}[htb] \begin{mdframed} % un solo riquadro esterno per coerenza visiva \centering % --- PRIMA SUBFIGURE --- \begin{subfigure}[t]{0.45\textwidth} \centering \begin{tikzpicture} \begin{axis}[ axis lines=none, grid=none, width=\linewidth, height=0.8\linewidth, % stessa altezza per entrambi xmin=-1, xmax=4, ymin=-2, ymax=3, samples=200, domain=0:3.1416 ] \addplot[thick,smooth]{2*sin(deg(x))}; \addplot[only marks, mark=*] coordinates {(0,0)}; \addplot[only marks, mark=*] coordinates {(3.1416,0)}; \node[below left] at (axis cs:0,0) {$x_0$}; \node[below right] at (axis cs:3.1416,0) {$x_1$}; \node[below] at (axis cs:1.5,1.9) {$\gamma(t)$}; \end{axis} \end{tikzpicture} \end{subfigure}% \hfill % --- SECONDA SUBFIGURE --- \begin{subfigure}[t]{0.45\textwidth} \centering \begin{tikzpicture} \begin{axis}[ axis lines=none, grid=none, width=\linewidth, height=0.8\linewidth, xmin=-1.5, xmax=1.5, ymin=-1.5, ymax=1.5, samples=200, domain=0:360 ] \addplot[thick, parametric] ({-0.5+0.5*cos(x)}, {0.5*sin(x)}); \addplot[only marks, mark=*] coordinates {(0,0)}; \node[right] at (axis cs:0,0) {$x_0$}; \node[left] at (axis cs:-1,0) {$\mu(t)$}; \end{axis} \end{tikzpicture} \end{subfigure} \hfill \begin{subfigure}[t]{0.45\textwidth} \centering \begin{tikzpicture} \begin{axis}[ axis lines=none, grid=none, width=\linewidth, height=0.8\linewidth, xmin=-1, xmax=4, ymin=-3, ymax=3, samples=200, domain=0:3.1416 ] \addplot[thick,smooth]{2*sin(deg(x))}; \addplot[thick,smooth]{-sin(deg(x))}; \addplot[only marks, mark=*] coordinates {(0,0)}; \addplot[only marks, mark=*] coordinates {(3.1416,0)}; \foreach \n in {1,...,9} { \pgfmathsetmacro{\t}{\n/10} \pgfmathsetmacro{\coef}{2 - 3*\t} \pgfmathtruncatemacro{\perc}{100*\t} \addplot[ smooth, thick, red!\perc!black, % gradiente dal verde al blu domain=0:3.1416, samples=200 ] {\coef*sin(deg(x))}; } \node[below left] at (axis cs:0,0) {$x_0$}; \node[below right] at (axis cs:3.1416,0) {$x_1$}; \node[above] at (axis cs:1.5,1.9) {$\gamma_0(t)$}; \node[below right] at (axis cs:2.5,-0.4) {$\gamma_1(t)$}; \end{axis} \end{tikzpicture} \end{subfigure} \hfill \begin{subfigure}[t]{0.45\textwidth} %is here in this subfigure the problem \centering \begin{tikzpicture} \begin{axis}[ axis lines=none, grid=none, width=\linewidth, height=0.8\linewidth, xmin=-1.5, xmax=1.5, ymin=-1.5, ymax=1.5, samples=200, domain=0:360 ] \foreach \n in {1,...,9} { \pgfmathsetmacro{\t}{\n/10} \pgfmathsetmacro{\coefa}{-0.5 + 0.25*\t} \pgfmathsetmacro{\coefb}{-\coefa} \pgfmathtruncatemacro{\perc}{100*\t} \addplot[thick, parametric]({\coefa +\coefb*cos(x)},{\coefb*sin(x)}); }; \addplot[thick, parametric] ({-0.5+0.5*cos(x)}, {0.5*sin(x)}); \addplot[only marks, mark=*] coordinates {(0,0)}; \node[right] at (axis cs:0,0) {$x_0$}; \node[left] at (axis cs:-1,0) {$\mu_0(t)$}; \node[right] at (axis cs:-0.55,0) {$\mu_1(t)$}; \end{axis} \end{tikzpicture} \end{subfigure} \hfill \end{mdframed} \caption{Main Caption} \end{figure} \end{document} And the result is

  • pgfplots: declare function and parameters globally
    by PatrickT on November 1, 2025 at 12:11 am

    As I was intent on moving function declarations further up, so as to use them in multiple files, I noticed something unexpected. The first code plots a thin black line. The second code plots thick blue dots. I asked a well-known LLM and got a plausible explanation together with a hallucination. Do you have a suggestion to declare functions higher up while preserving the style? See a motivation further down. Example 1 \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \tikzset{define functions/.style={% declare function={ A = 1.0; a = 0.5; f(\x) = A*\x^a; }, }, } \begin{document} \begin{tikzpicture} \begin{axis}[ domain=0:100, samples=100, ] \addplot[define functions] {f(x)}; \end{axis} \end{tikzpicture} \end{document} Example 2 \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \tikzset{define functions/.style={% declare function={ A = 1.0; a = 0.5; f(\x) = A*\x^a; }, }, } \pgfplotsset{ every axis plot/.append style={define functions}, } \begin{document} \begin{tikzpicture} \begin{axis}[ domain=0:100, samples=100, ] % [define functions] not used here \addplot {f(x)}; \end{axis} \end{tikzpicture} \end{document} LLM talking now: Example 1 \addplot[define functions] {f(x)}; You explicitly attach the define functions style only to that plot. No other styles are affected. PGFPlots uses the default plot style, which is a thin black line (black, line width 0.4pt). Example 2 \pgfplotsset{every axis plot/.append style={define functions}} \addplot {f(x)}; You append the define functions style to every plot. But here’s the subtlety: every axis plot applies before the default plot style is applied, and declare function is a key that is not strictly separate from plotting keys. What happens internally: PGFPlots interprets your appended style as including both the function declaration and the style from the first plot in your style list. Because of key expansion order, the default line style is overridden. The plot falls back to the first "unknown" style PGFPlots sees for drawing, which is often the blue mark=* style (used for points), producing thick blue dots. Why this happens every axis plot is applied before \addplot options are merged. declare function is technically a "style key" in the PGFPlots system. PGFPlots sees a style (from every axis plot) that contains no explicit draw key, so it falls back to its default marker style (mark=*, thick, blue). When you attach [define functions] directly to \addplot, the default line style is preserved, so you get a thin black line. How to fix it You need to combine your define functions style with the standard line style: if you want to keep PGFPlots defaults but still append: \pgfplotsset{ every axis plot/.append style={define functions, /pgfplots/line} } Me speaking again: No this doesn't work and nor do the several other suggestions I received. Motivation: I would save different parameter values in distinct files and load them with, say \input{func1.tex}, so I can share code across multiple figures. The syntax used in declare function is natural, unlike an alternative like \pgfmathdeclarefunction{f}{1}{\pgfmathparse{1.0*#1^(0.5)}}. I'm not averse to trying something radically different from my current approach, including using LuaTeX or Python.

  • Arrows along path are misaligned after unrelated calculations
    by PatrickT on October 27, 2025 at 7:08 am

    The objective is to draw arrows that show convergence to a particular coordinate. The code below has served me well in simple cases. But attempting to use coordinates calculated with the intersections library caused a vertical misalignment. In the MWE the derived coordinates are not even used: the misalignment seems to be caused by the calculations. I would appreciate help fixing the issue. Any other advice to optimize the code is welcome. \documentclass[border=3pt,tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{calc} \usetikzlibrary{intersections} % set up all axes \pgfplotsset{% every axis/.append style={% axis styles xmin = 0, xmax = 250, ymin = 0, ymax = 60, ticks = none,% remove all ticks grid = none,% remove all grids clip = false,% remove clip },% }% % Define coordinates \newcommand{\SetCoordinates}{% % coordinates \coordinate (A) at (0,30); \coordinate (B) at (100,0); % calculations below interfere somehow... % define first path \addplot [draw=none, forget plot, domain=-1:200, restrict y to domain=-1:100, name path global=first path] {sqrt(x)}; % define second path \addplot [draw=none, forget plot, domain=-1:200, restrict y to domain=-1:100, name path global=second path] {0.10*x}; % find the intersection of first path and second path \path [name intersections={of=first path and second path, by={E}}]; }% % define styles for arrows along path \usetikzlibrary{arrows} \usetikzlibrary{decorations.markings} % see: https://tikz.dev/library-decorations#sec-50.2 \usetikzlibrary{fpu}% use with [/pgf/fpu/install only={reciprocal}] \tikzset{ set arrows onpath/.code={\pgfqkeys{/tikz/arrows onpath}{#1}}, set arrows onpath={end/.initial=>, opt/.initial=}, /pgf/decoration/Mark/.style={ mark/.expanded=at position #1 with { \noexpand\arrow[\pgfkeysvalueof{/tikz/arrows onpath/opt}]{\pgfkeysvalueof{/tikz/arrows onpath/end}} } }, arrows onpath/.style 2 args={ set arrows onpath={#1}, postaction={ decorate,decoration={ markings, Mark/.list={#2}, },% },% },% }% % Arrow | x-axis | Convergence \NewDocumentCommand{\hArrows}{ m O{ 30pt } }{% \path [draw=none, arrows onpath={end=latex, opt={black,scale=0.9}}{0.50,0.75,1.00}] ($(#1)+(+#2,0)$) -- (#1); \path [draw=none, arrows onpath={end=latex, opt={black,scale=0.9}}{0.50,0.75,1.00}] ($(#1)+(-#2,0)$) -- (#1); }% % Arrow | y-axis | Convergence \NewDocumentCommand{\vArrows}{ m O{ 30pt } }{% \path [draw=none, arrows onpath={end=latex, opt={black,scale=0.9}}{0.50,0.75,1.00}] ($(#1)+(0,+#2)$) -- (#1); \path [draw=none, arrows onpath={end=latex, opt={black,scale=0.9}}{0.50,0.75,1.00}] ($(#1)+(0,-#2)$) -- (#1); }% \begin{document} \begin{tikzpicture} \begin{axis} \SetCoordinates \hArrows{B}[50pt] \vArrows{A}[10pt]% buggy \node [left, align=center, anchor=south west] at (40,20) {The vertical alignment\\ is thrown off\\ by the calculations inside\\ command \texttt{SetCoordinates}.\\ Why?}; \end{axis} \end{tikzpicture} \end{document}

  • `tikzviolinplots` produces `! Dimension too large.`
    by Rubem Pacelli on October 19, 2025 at 7:26 pm

    %%% featues %%% % violinplot % CAVEAT: run it as `latexmk -pdf -shell-escape -interaction=nonstopmode -g main.tex` %%% picture %%% % https://tex.stackexchange.com/a/679168/222785 \documentclass{article} \usepackage{pgfplots} \usepackage{tikzviolinplots} \usepackage{minted} \usepackage{scontents} % Ensure pgfplots uses a modern compat level \pgfplotsset{compat=newest} \usepgfplotslibrary{external} \usemintedstyle{gruvbox-light} \tikzexternalize \begin{scontents}[write-out=violinandboxplotexample.dat] trn,val 19.334,69.122 2.146,3.136 1.629,2.080 2.930,1.629 9.208,1.332 6.265,2.189 74.253,1.392 2.097,3.970 1.328,1.624 1.814,19.254 2.090,6.546 1.814,8.212 3.177,3.484 2.239,2.601 1.213,1.565 2.697,9.208 1.550,4.145 19.254,2.770 5.409,2.318 1.679,2.357 1.392,67.159 2.697,3.047 4.592,2.021 1.671,1.583 6.265,1.294 13.373,2.127 3.216,1.353 3.143,3.858 3.779,1.578 74.253,18.707 3.779,6.360 1.580,7.979 1.642,3.385 1.580,2.527 2.189,1.520 1.665,8.946 1.696,4.027 2.041,2.692 2.770,2.252 4.145,2.290 2.207,60.506 1.671,2.745 3.216,1.821 7.512,1.426 3.970,1.166 1.624,1.916 1.307,1.219 2.163,3.475 3.136,1.422 1.665,16.854 4.465,5.730 9.766,7.189 4.465,3.049 1.703,2.277 1.702,1.370 1.550,8.060 2.892,3.628 4.592,2.425 1.213,2.029 5.409,2.063 3.830,68.544 3.840,3.110 19.334,2.063 8.212,1.615 1.362,1.321 1.220,2.171 1.362,1.381 1.220,3.937 3.484,1.611 2.239,19.093 5.560,6.491 1.642,8.144 2.357,3.454 9.766,2.579 2.163,1.552 5.560,9.131 1.703,4.111 2.041,2.747 2.138,2.298 3.830,2.338 %10.174,70.018 % UNCOMMENT TO SEE THE CHAOS \end{scontents} \tikzexternaldisable \begin{document} \begin{tikzpicture} \violinsetoptions[ % averages, data points, scaled, ]{ xmin=0,xmax=5, ymin=0,ymax=100, xlabel style={ yshift = {-2*height("a")} }, ymajorgrids=true, ylabel={Same property}, } \violinplotwholefile[% primary color=red, secondary color=blue, indexes={trn,val}, spacing=1.0, labels={% $\alpha$, $\beta$, $\gamma$, $\delta$, }, col sep=comma, dataset size=1pt, dataset mark=*, dataset fill=black!50!white, dataset fill opacity=1.0, average mark=x, average size=5pt, ]{violinandboxplotexample.dat} \end{tikzpicture} \end{document} Uncommenting that line in this MWE leads to: ! Dimension too large. <recently read> \pgfmath@x l.141 ]{violinandboxplotexample.dat} How to fix that?

  • Why is my Student's t-distribution plotting incorrectly in pgfplots?
    by lane-h-rogers on September 22, 2025 at 10:45 pm

    I am trying to plot a Student's t distribution without using gnuplot. Here is what I have been trying: \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \pgfmathdeclarefunction{gamma}{0}{% \pgfmathparse{sqrt(2*pi*x)*(x/e)^(x)} % *exp(1/(12*x)) } \pgfmathdeclarefunction{tdist}{1}{% \pgfmathparse{(gamma(#1/2 + 1/2)/(sqrt(#1*pi)*gamma(#1/2)))*((1 + (x^2)/#1)^(-#1/2 - 1/2))} % #1 is df } \begin{tikzpicture} \begin{axis}[ thick, no markers, domain=-10:10, samples=400, axis x line*=bottom, axis y line*=middle, x axis line style={draw opacity=100,color=blue}, y axis line style={draw opacity=100,color=blue}, xlabel=$t_{8}$, ylabel=$P(x)$, every axis y label/.style={at=(current axis.above origin),anchor=south}, every axis x label/.style={at=(current axis.right of origin),anchor=west}, height=4cm, width=8cm, xtick={0}, xticklabels={$\mu=0$}, ytick={1}, enlargelimits=false, clip=false, axis on top, grid = major ] \addplot{tdist(8)}; \end{axis} \end{tikzpicture} \end{document} This yields the plot: which is clearly not correct, as a t distribution should have a peak with height roughly P(x) = .4. I have already checked the formula many times and cannot find an error. Does anyone have an idea of what is going wrong? Is it possibly due to the imprecision inherent in Stirling's approximation of the gamma function?

  • pgfplots: Using set layers in an overlay picture
    by schtandard on July 5, 2025 at 1:58 pm

    Using pgfplots, I want to draw a plot as an overlay picture, making use of layers inside that plot. However, when I say \begin{tikzpicture} [overlay] \pgfplotsset{set layers} \begin{axis} \end{axis} \end{tikzpicture} I get two ! Dimension too large. errors. pgfplots seems to attempt to set both unit lengths (\pgf@x and \pgf@y) to -32000.0pt. Why is that and how can I avoid it? For tinkering, here is a slightly more useful MWE. Interestingly, the result looks fine in this example. (In larger pictures, the errors do cause havoc, though.) \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} [remember picture] \draw [green] coordinate (test) circle [radius=5cm]; \end{tikzpicture} \begin{tikzpicture} [remember picture, overlay] \pgfplotsset{set layers} \begin{axis} [at=(test), anchor=center, ymajorgrids] \addplot+ {x^2}; \begin{pgfonlayer}{axis grid} \fill [red] (axis cs:3,20) circle [radius=2cm]; \end{pgfonlayer} \end{axis} \end{tikzpicture} \end{document}

  • pgfplots / 2D contour filled plot from a csv file
    by TheBeeTee on December 1, 2024 at 11:19 pm

    Trying to plot a 2D colormap of my data like this: Here's my MWE with a sample of data. x,y are the coordinates. P is the value on which I want to base the shading. \documentclass[border=1 cm]{standalone} \usepackage{pgfplots} \begin{document} \begin{filecontents}{test.csv} x,y,P 0.6029680189,0.7383407645,2.3729000000 0.5323565117,0.6601831742,3.2726000000 0.4677196601,0.5882540709,4.0038000000 0.0946800948,0.6688882286,5.0510000000 0.1884371445,0.6355349568,5.0222000000 0.2792665104,0.5997515545,4.8900000000 0.3623180375,0.5641482523,4.6771000000 0.4853625211,0.1178246418,5.0150000000 0.4696592171,0.2354673908,4.9738000000 0.4525723312,0.3510530681,4.8490000000 0.4353225341,0.4584688067,4.6566000000 \end{filecontents} \begin{tikzpicture} \begin{axis}[ view = {0}{90}, colorbar, ] \addplot3[ contour filled={number = 20} ] table[x=x, y=y, z=P, col sep=comma]{test.csv}; \end{axis} \end{tikzpicture} \end{document} The code above was throwing: ERROR: shader=interp: got unsupported pdf shading type '0'. *****After more searching, I modified my MWE as follows. I don't get any errors, I just get an empty plot 🙁 \documentclass[border=1 cm]{standalone} \usepackage{pgfplots} \usepgfplotslibrary{patchplots} \begin{document} \begin{filecontents}{test.csv} x,y,P 0.6029680189,0.7383407645,2.3729000000 0.5323565117,0.6601831742,3.2726000000 0.4677196601,0.5882540709,4.0038000000 0.0946800948,0.6688882286,5.0510000000 0.1884371445,0.6355349568,5.0222000000 0.2792665104,0.5997515545,4.8900000000 0.3623180375,0.5641482523,4.6771000000 0.4853625211,0.1178246418,5.0150000000 0.4696592171,0.2354673908,4.9738000000 0.4525723312,0.3510530681,4.8490000000 0.4353225341,0.4584688067,4.6566000000 \end{filecontents} \begin{tikzpicture} \begin{axis}[ %view = {0}{90}, colorbar, ] \addplot[contour filled={number = 8,labels={false}}, mesh/rows=100,mesh/cols=100,mesh/check=false, patch type=bilinear, point meta=explicit, ] table [x=x, y=y, z=P, col sep=comma]{test.csv}; \end{axis} \end{tikzpicture} \end{document}

  • How to add space between x axis labels and draw a vertical line after a set of IDs?
    by Student on November 21, 2024 at 8:13 pm

    I'm trying to add space between x axis labels 10 Flows, 20 Flows, and 30 Flows and also properly draw a line after for every 1 to 8 IDs. Could someone help me with this problem? Code: % restructured data file: % - 'n' values are sorted ascending % - added column 'z' to know which data belong to which measurement % - added a dummy line at the end of each data set to produce an empty entry % for the separation of the blocks % - put all data in one file \begin{filecontents}{data.txt} z n pFA pFB 10 1 6 1 10 2 7 1 10 3 8 4 10 4 9 7 10 5 10 9 10 6 0 0 10 7 9 4 10 8 12 6 20 1 6 1 20 2 7 1 20 3 8 4 20 4 9 7 20 5 10 9 20 6 0 0 20 7 9 4 20 8 12 6 30 1 6 1 30 2 7 1 30 3 8 4 30 4 9 7 30 5 10 9 30 6 0 0 30 7 9 4 30 8 12 6 \end{filecontents} \documentclass[border=5pt]{standalone} \usepackage{pgfplots} \usetikzlibrary{patterns} \pgfplotsset{compat=1.3} \begin{document} \begin{tikzpicture} \begin{axis}[ footnotesize, % set the `width' of the plot to the maximum length ... width=\textwidth, % ... and use half this length for the `height' height=0.5\textwidth, ymin=0, ymax=100, %yticklabel=\pgfmathprintnumber{\tick}\,$\%$, % use `data' for the positioning of the `xticks' ... xtick=data, % ... and use table data for labeling the `xticks' xticklabels from table={data.txt}{n}, % add extra ticks "at the empty entries to add the vertical lines extra x ticks={8,16}, % this ticks shouldn't be labeled ... extra x tick labels={}, % ... but grid lines should be drawn without the tick lines extra x tick style={ grid=major, major tick length=0pt, }, xlabel={X Axis Label}, ylabel={Y Axis Label}, % because of the category labels, shift the `xlabel' a bit down xlabel style={ yshift=-4ex, }, legend pos=north west, legend entries={ {\color{black}{Algorithm A}}, {\color{red}{Algorithm B}}, }, area legend, % adjust `bar width' so it fits your needs ... bar width=10pt, % ... and with that you also have to adjust the x limits enlarge x limits=0.05, % set `clip mode' to `individual' so the category labels aren't clipped away clip mode=individual, ] % plot the "red" ybars \addplot [ ybar, draw=black, pattern color=black, pattern=dots, ] table [ % use just the `coordindex' as x coordinate, % the correct labeling is done with `xticklabels from table' x expr=\coordindex, y=pFA, ] {data.txt}; % plot the "blue" ybars \addplot [ ybar, draw=red, pattern color=red, pattern=north east lines, ] table [ x expr=\coordindex, y=pFB, ] {data.txt}; % add the category labels \begin{scope}[ % because the reference point will be the lower axis line the % labels have to be moved a bit more down to don't overlap with % the `xticklabels' every label/.append style={ label distance=2ex, }, ] \node [label=below:10 Flows] at (axis cs:4,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:20 Flows] at (axis cs:12,\pgfkeysvalueof{/pgfplots/ymin}) {}; \node [label=below:30 Flows] at (axis cs:20,\pgfkeysvalueof{/pgfplots/ymin}) {}; % \node [label=below:40 Flows] % at (axis cs:20,\pgfkeysvalueof{/pgfplots/ymin}) {}; %\node [label=below:50 Flows] % at (axis cs:26,\pgfkeysvalueof{/pgfplots/ymin}) {}; \end{scope} \end{axis} \end{tikzpicture} \end{document} Output:

  • Tikz externalization with luacode
    by pschulz on October 23, 2024 at 1:57 pm

    I'm using luacode environments to assemble plot code for pgfplots. For many plots that works perfectly fine even with tikzexternalize. However, I have one plot where it does not work and the error message is cryptic. I reduced it to: \documentclass{article} \usepackage{pgfplots} \usepackage{luacode} \usetikzlibrary{external} \tikzexternalize \begin{document} %\tikzexternaldisable % doesn't compile with externalization, don't know why \begin{tikzpicture} \begin{axis} \begin{luacode*} local t = {} table.insert(t, "(0, 0)") table.insert(t, "(1, 1)") tex.print("\\addplot coordinates {") tex.print(table.concat(t)) tex.print("};") \end{luacode*} \end{axis} \end{tikzpicture} \end{document} So I used to get an error message like this: File ended while scanning use of \tikzexternal@laTeX@collect@until@end@tikzpicture I thought it might be related to a percent sign in the lua code (which I used for string.format), but I removed them. Now the strings are assembled a bit more manually. The problem persists, however, I don't get an error message any more. It just fails and it also does not create a main-figure0.log file, only the .md5 file. So what is going on?

  • How can I remove the Labels of the blue dots on the left plot and change the position of label nr16 in the right plot?
    by dan1365 on March 30, 2023 at 9:46 am

    \documentclass[11pt]{report} \usepackage{pgfplots, pgfplotstable} \pgfplotsset{width=10cm,compat=1.18} \usepackage{graphicx} \usepackage{caption} \usepackage{subcaption} \begin{document} \begin{figure} \centering \begin{subfigure}[tb]{0.48\linewidth} \begin{tikzpicture} \begin{axis}[height=7cm, width=\linewidth, xlabel={}, ylabel={}, ytick={0,500,...,1700}, xtick={0,500,...,1700}, ymin=-170, ymax=1700, xmin=-170, xmax=1700, ymajorgrids, xmajorgrids] \addplot[ scatter/classes={0={blue}, 1={red}}, scatter, mark=*, only marks, scatter src=explicit symbolic, nodes near coords*={\Label}, visualization depends on={value \thisrow{label} \as \Label} %<- added value ] table [meta=class] { x y class label 0.3788 8.1653 0 - 6.3716 4.0196 0 - 0.4225 0.1447 0 - 14.8118 6.6124 0 - 2.7433 2.544 0 - 152.0046 30.6336 1 5 1375 428.5714 1 6 20.51 5.1280 0 - 38.8548 1492.8425 1 8 0.1409 0.000196 0 - }; \end{axis} \end{tikzpicture} \caption{} \label{} \end{subfigure}\hfill \begin{subfigure}[tb]{0.48\linewidth} \begin{tikzpicture} \begin{axis}[height=7cm, width=\linewidth, xlabel={}, ylabel={}, ytick={0,2,...,10}, xtick={0,5,...,20}, ymin=-1.133, ymax=11.333, xmin=-2.266, xmax=22.666, ymajorgrids, xmajorgrids] \addplot[ scatter/classes={0={blue}, 1={red}}, scatter, mark=*, only marks, scatter src=explicit symbolic, nodes near coords*={\Label}, visualization depends on={value \thisrow{label} \as \Label} %<- added value ] table [meta=class] { x y class label 0.3788 8.1653 0 9 6.3716 4.0196 0 10 0.4225 0.1447 0 12 14.8118 6.6124 0 13 2.7433 2.544 0 14 20.51 5.1280 0 15 0.1409 0.000196 0 16 }; \end{axis} \end{tikzpicture} \caption{} \label{} \end{subfigure}\hfill \caption{} \end{figure} \end{document} > Blockquote

  • Calculate the value of definite integrals?
    by fsbmat on October 17, 2022 at 7:00 pm

    I am trying to create a package for LaTeX, in this package I will need, if possible, to calculate the value of definite integrals. Is there a possibility to do this in LaTeX? Using for example the pgf package?

  • Custom numbering of figures
    by Gennaro Arguzzi on December 19, 2017 at 8:53 pm

    I'd like to number figures in a custom way. For example: fig. 1, fig. 2a, fig. 2b, fig. 3 (among figures there is text). \documentclass[10pt,a4paper]{report} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{pgfplots} \begin{document} Bla bla bla \begin{figure}[h] \centering \begin{center} \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture} \end{center} \caption{Es.} \end{figure} Bla bla bla \begin{figure}[h] \centering \begin{center} \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture} \end{center} \caption{Es.} \end{figure} bla bla \begin{figure}[h] \centering \begin{center} \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture} \end{center} \caption{Es.} \end{figure} bla \begin{figure}[h] \centering \begin{center} \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture} \end{center} \caption{Es.} \end{figure} \end{document} Thank you so much for your time.

  • Change color of \addplot in a \foreach loop (pgfplots)
    by Benjamin1956 on February 14, 2017 at 11:38 am

    I have this pgfplots plot and I want every single graph to have a different color. A gradient from red to blue or something else (m=2 should be red, m=11 should be blue and all the other m should be between this). I need this to work even when I change the amount of graphs. I already tried to transfer the code lines from this example, but I can't get it working: Plotting a graph with several values of a parameter The minimum working example is added below. Thank you. \documentclass[12pt]{article} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage{pgfplots} \pgfplotsset{compat=newest} \pgfplotsset{ gainplot/.style={ axis x line*=box, xmax=10, xmin=0.1, xmode=log, width=14cm, xlabel=$F_\textup{x}$, xticklabel style={yshift=-0.2cm,}, xtick={0.1,1.0,10.0}, xticklabels={{$0.1$},{$1.0$},{$10.0$}}, axis y line*=box, ymax=3, ymin=0, ymode=normal, height=7cm, ylabel=$K$, yticklabel style={xshift=-0.2cm,}, ytick={0,1,2,3 }, yticklabels={{$0$},{$1$},{$2$},{$3$}}, grid = both, grid style={line width=0.2pt,}, legend style={ font=\scriptsize, at={(0.5,1.03)}, anchor=south, draw=none, }, legend columns=5, }, gainplot/.belongs to family=/pgfplots/scale, } \pgfmathdeclarefunction{gaincurve}{2}{% \pgfmathparse{% (x^2*(#2-1)/(sqrt((#2*x^2-1)^2+x^2*(x^2-1)^2*(#2-1)^2*#1^2))) }% } \tikzstyle{gaincurvestyle}=[ smooth, %thick, mark=none, domain=0.1:10, samples=100, ] \begin{document} \begin{figure}[] \centering \begin{tikzpicture} \begin{axis}[gainplot] \foreach \m in {2,3,...,11}{ \addplot[gaincurvestyle,red]{gaincurve(0.2,\m)}; %%% Here help is needed. \addlegendentryexpanded{$m=\m$} } \end{axis} \end{tikzpicture} \caption{Placeholder.} \end{figure} \end{document}