• PGFPlots Line Patch Plot with Decoration
    by trumpeter201 on October 21, 2025 at 9:08 pm

    Using tikz and PGFPlots, I am creating a patch plot from data table with the line patch type. I would like to decorate the end of each line with an arrow. What is the best way to do this? Below is a minimal example, missing the arrow decorations. Note that I need to use the table syntax to generate the plot, as the real data is stored in a large text file. \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepgfplotslibrary{patchplots} \begin{document} \begin{tikzpicture}[] \begin{axis}[] \addplot[patch, patch type = line] table { x y 0 0 0 1 0 0 1 1 0 0 1 0 }; \end{axis} \end{tikzpicture} \end{document} This code generates the following plot:

  • `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?

  • Backward bifurcation diagram on latex [closed]
    by Shadreck Hero Ngomane on October 16, 2025 at 5:52 pm

    Please assist drawing bifurcation diagram I have attached a photo on how is suppose to look like. some additions \documentclass[12pt]{article} \usepackage{amsmath, amssymb} \begin{document} \begin{itemize} \item \textbf{Axes:} The horizontal axis represents the control reproduction number $\mathcal{R}_c$ (increasing rightward), while the vertical axis represents the equilibrium infection level $\lambda^*$ (increasing upward). \item \textbf{Curve structure:} The equilibrium curve is quadratic-like, showing two positive equilibrium branches that merge at a turning point (saddle-node), where $\Delta = 0$ and $\lambda_b = -\tfrac{C_2}{2C_1}$. \item \textbf{Lower stable branch:} This branch exists for $\mathcal{R}_c < 1$, indicating that a stable endemic equilibrium can persist even when the threshold condition $\mathcal{R}_c < 1$ is satisfied. Hence, reducing $\mathcal{R}_c$ below one may not suffice to eradicate infection. \item \textbf{Saddle-node (turning) point:} At $\mathcal{R}_c = \mathcal{R}_c^{\mathrm{crit}} < 1$, two equilibria (one stable and one unstable) coalesce and disappear, corresponding to the backward bifurcation point. \item \textbf{Unstable branch:} Lies between the two stable branches (often shown as a dashed line), separating the basins of attraction of the disease-free and endemic equilibria. \item \textbf{Transcritical point:} At $(\mathcal{R}_c = 1, \lambda^* = 0)$, the disease-free equilibrium (DFE) loses stability and the upper endemic equilibrium branch emerges. \item \textbf{Upper stable branch:} Represents the endemic equilibrium for $\mathcal{R}_c > 1$, which is globally stable when $\mathcal{R}_c$ is sufficiently large. \end{itemize} \begin{itemize} \item For $\mathcal{R}_c < \mathcal{R}_c^{\mathrm{crit}}$: only the DFE exists and is stable. \item For $\mathcal{R}_c^{\mathrm{crit}} < \mathcal{R}_c < 1$: two positive equilibria exist—one stable and one unstable. \item For $\mathcal{R}_c > 1$: only the endemic equilibrium exists and is stable. \end{itemize} \end{document}

  • Loop over pgfplotstable rows and axis, or any other method
    by username on October 14, 2025 at 1:14 pm

    I would like to create a graphic that does what this file is doing,but without going through each individual line \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{loglogaxis}[ xlabel=Energy, ylabel=GDP, title={Data: Energy vs GDP}, grid=both, xmin=1000, xmax=100000, ymin=1000000, ymax=1000000000, xtick={1000, 10000, 100000}, ytick={1000000, 10000000, 100000000, 1000000000}, xticklabels={$10^3$, $10^4$, $10^5$}, yticklabels={$10^6$, $10^7$, $10^8$, $10^9$} ] % Add circles \filldraw[blue, opacity=0.3] (axis cs:1981.7102,40578847) circle (6.37015282391247*1pt); \filldraw[blue, opacity=0.3] (axis cs:17111.953,2827614) circle (1.68155106969726*1pt); \filldraw[blue, opacity=0.3] (axis cs:14782.2,45477391) circle (6.74369268279627*1pt); \filldraw[blue, opacity=0.3] (axis cs:7397.4863,35635028) circle (5.96950818744727*1pt); \filldraw[blue, opacity=0.3] (axis cs:7888.164,169384891) circle (13.0147950809838*1pt); \filldraw[blue, opacity=0.3] (axis cs:38214.496,145579889) circle (12.0656491329725*1pt); \filldraw[blue, opacity=0.3] (axis cs:72679.26,341534041) circle (18.4806396263766*1pt); % Add labels \node[] at (axis cs:1981.7102,40578847) {}; \node[] at (axis cs:17111.953,2827614) {}; \node[] at (axis cs:14782.2,45477391) {}; \node[] at (axis cs:7397.4863,35635028) {}; \node[] at (axis cs:7888.164,169384891) {Bangladesh}; \node[] at (axis cs:38214.496,145579889) {Russia}; \node[] at (axis cs:72679.26,341534041) {United States}; \end{loglogaxis} \end{tikzpicture} \end{document} I have tried using a \foreach loop, something like \pgfplotstableread[col sep = comma]{ x,y,r,l 1981.7102,40578847,6.37015282391247, 17111.953,2827614,1.68155106969726, 14782.2,45477391,6.74369268279627, 7397.4863,35635028,5.96950818744727, 7888.164,169384891,13.0147950809838,Bangladesh 38214.496,145579889,12.0656491329725,Russia 72679.26,341534041,18.4806396263766,United States }\mytable and within the plot \foreach \row in {0,...,4} { \pgfplotstablegetelem{\row}{x}\of\mytable \let\x=\pgfplotsretval \pgfplotstablegetelem{\row}{y}\of\mytable \let\y=\pgfplotsretval \pgfplotstablegetelem{\row}{r}\of\mytable \let\r=\pgfplotsretval \pgfplotstablegetelem{\row}{l}\of\mytable \let\t=\pgfplotsretval \draw[blue, opacity=0.3] at ({\x}, {\y}) circle (\r*5pt); \node[font=\tiny] at (\x, \y) {\t}; but that fails when i do it within the axis framework.

  • Pgfplots -- Make units exactly 1 cm
    by klirk on October 13, 2025 at 1:56 pm

    I am trying to make a pgf plot so that when printed, the units are exactly 1 cm, i.e, the grid lines should be 1 cm apart. However, whatever I do, I cannot make it work and I really don't know why. This is my minimal example: \documentclass[a4paper]{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ width=6cm, height=6cm, scale only axis, enlargelimits=false, xmin=0, xmax=6, ymin=0, ymax=6, grid=both, xtick={0,1,...,6}, ytick={0,1,...,6}, ] \end{axis} \end{tikzpicture} \end{document} When I print the pdf and measure distances with a ruler, the grid lines have distance slightly smaller than 1cm, resulting in a size of around 5.7 cm instead of 6 cm for the entire axis.

  • Undesirable slant in ylabel in pgfplots
    by Scholar on October 11, 2025 at 3:20 am

    I am trying to plot multiple curves, of which some are trigonometric, on the same plot. However, the ylabel appears to be slanted every time I use trig format=rad in my code. If I remove this, everything works fine and the label appears the way I expect it to (standard ylabel). Here is the MWE. Any help leading to a fix is highly appreciated. \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage{geometry} \begin{document} \begin{tikzpicture} \begin{axis}[ trig format=rad, ylabel={This is a test label}, xlabel={$t$ (s)}, grid=both, axis lines=box, xmin=0, xmax=20, ] \addplot [blue, thick, domain=0:20, samples=100] {2*(1-cos(x))}; \end{axis} \end{tikzpicture}

  • How do I prevent "see-through" when overlaying a surf plot with a point cloud?
    by Peter1509 on October 10, 2025 at 3:08 pm

    I am trying to create a surf plot with an additional point cloud on top. The data for both is saved in two different tables, which are then read and plottet into the same axis environment. Currently I have the problem, that some points (which are actually covered by the surf plot) can be seen through the surface. I want only be able to see the points, which from the given view perspective are not covered by some part of the surface plot. I already tried the pgfplot option \pgfplotsset{set layers}, but it didn't change anything. Also the order of \addplot3 -commands had no influence on the resulting plot. Are there any other options to solve my problem? Here is the important part of my current code structure: \pgfplotsset{set layers} \begin{tikzpicture} \begin{axis}[% width=0.65\figurewidth, height=1.2\figureheight, at={(0\figurewidth,0\figureheight)}, scale only axis, xmin=0, xmax=20, xtick distance = 5, tick align=outside, xlabel style={font=\color{white!15!black}}, xlabel={$t$ in \si{\hour}}, ymin=0, ymax=0.605, ylabel style={font=\color{white!15!black}}, ylabel={$z$}, zmin=0, zmax=220, ztick distance = 50, zlabel style={font=\color{white!15!black}}, zlabel={$x(z,t)$}, view={-35}{60}, axis background/.style={fill=white}, title style={font=\bfseries}, axis x line*=bottom, axis y line*=left, axis z line*=left, xmajorgrids, ymajorgrids, zmajorgrids, ylabel near ticks, xlabel near ticks, title style={font=\small}, xlabel style={font=\footnotesize, yshift = 2mm}, ylabel style={font=\footnotesize, yshift = 1mm,xshift = 5mm}, xticklabel style ={/pgf/number format/fixed, /pgf/number format/precision=3}, ylabel style={font=\footnotesize, rotate=-90}, yticklabel style ={/pgf/number format/fixed, /pgf/number format/precision=3,/pgf/number format/use comma}, zticklabel style = {yshift = -2.5mm}, zlabel shift={-5pt}, zlabel style = {xshift = -3mm}, legend style={font=\scriptsize}, ticklabel style={font=\scriptsize} ] \addplot3 [only marks, mark=*, mark options={}, mark size=1.0607pt, color=red, fill=red, forget plot, z buffer=sort] table[meta index = 2, col sep=tab, x expr=\thisrowno{0}/3600, y index=1] {tikz/Simulationsplots/xzt_chebypoints-2.tsv}; \addplot3[% surf, shader=flat corner, colormap={mymap}, mesh/rows=30, z buffer=sort] table[col sep=tab, x expr=\thisrowno{0}/3600, y index=1] {% tikz/Simulationsplots/xzt_chebypoints-1.tsv}; \end{axis} \end{tikzpicture}%

  • How to add extra y ticks to a pgfplots axis on the right with fixed width?
    by Tristan Nemoz on October 10, 2025 at 8:39 am

    I have the plot of several functions on a single axis, and I would like to add extra y ticks on the right of the plot to show the different numbers to which these functions converge to. However, I can't manage to have the total tikzpicture to be \textwidth wide, the extra ticks label making an overfull hbox. MWE: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[ xlabel=$x$, ylabel={$f(x) = x$}, width=\textwidth, height=\axisdefaultheight, extra y ticks={1}, extra y tick labels={\(\log_2(5)-\sum_ii\)}, extra y tick style={ yticklabel pos=right, grid=major, major grid style={gray, thin, densely dashed}, }, ] \addplot {x}; \end{axis} \end{tikzpicture} \end{document} I've tried the solution of this answer to no avail, it still results in an overfull hbox: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[ xlabel=$x$, ylabel={$f(x) = x$}, width=\textwidth, height=\axisdefaultheight, extra y ticks={1}, extra y tick labels={\makebox[0pt][l]{\(\log_2(5)-\sum_ii\)}}, extra y tick style={ yticklabel pos=right, grid=major, major grid style={gray, thin, densely dashed}, yticklabel style={ % add a name to the extra y tick label name=ylabel-\ticknum, }, }, ] \addplot {x}; \end{axis} \pgfmathsetlengthmacro{\MyExtraLabel}{width("$\log_2(5)-\sum_ii$")} \path (ylabel-0) -- +(\MyExtraLabel,0); \end{tikzpicture} \end{document} Finally, I also tried using a second axis environment, as in this answer, once again to no avail: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[ xlabel=$x$, ylabel={$f(x) = x$}, width=\textwidth, height=\axisdefaultheight, ] \addplot {x}; \end{axis} \begin{axis}[ width=\textwidth, height=\axisdefaultheight, hide x axis, axis y line*=right, ymin=-6, ymax=6, ytick=\empty, extra y ticks={1}, extra y tick labels={\(\log_2(5)-\sum_ii\)} ] \addplot[draw=none] {x}; % dummy plot \end{axis} \end{tikzpicture} \end{document} Also, this solution would force me to know the ymin and ymax of the first plot if I'm not mistaken, which isn't convenient. Is there a way to make these extra ticks on the right taken into account when computing the width of the end figure?

  • Adding a colormap to a solution curve of a vector field
    by Black Mild on October 7, 2025 at 8:29 pm

    Here the curve is drawn with a single color (red) It's easy to get the solution curve. The below figure is drawn in this app for y'=x^2+y^2-1, y(0)=1/2. As you can notice the color of the curve is varying from red (x<-1) to purple (-1<x<1) then to blue (x>1). It is not color set of the rainbow, so it is not synchronious to the Rainbow colormap. My question: How to add a given colormap (such as Rainbow) to a solution curve of a vector field? I guess this is a kind of popular, but can not find a way with Asymptote. I expect not only Asymptote code but also any others as TikZ, MetaPost, lua, etc. The code should be apply for any colormaps Please use my code here as MWE.

  • How to create tick labels on the outer bounds of the plot, not along the axes?
    by Vladimir Tsitrin on September 30, 2025 at 5:20 pm

    Need to add tick labels on the outside boundaries of the plot like on the pic below. Without axes explicitly displayed it works by default but after I add axes the labels are displayed inside the plot along the axes. Code: \documentclass[12pt,openany]{book} \usepackage{wrapfig,epsfig,amsmath} \usepackage{amssymb,rotating,pgfplots,subfigure} \usepackage{graphicx,subcaption,ragged2e,enumitem} \pgfplotsset{compat=newest, width=10cm} \usepackage{braket} \usepackage{nicefrac} \usepackage{url} \usepackage{stix} \usepackage{array} \usepackage{tikz} \usetikzlibrary{intersections} \usetikzlibrary{arrows.meta} \usetikzlibrary{topaths} \usetikzlibrary{positioning} \usetikzlibrary{shapes.geometric} \usetikzlibrary{backgrounds} \usetikzlibrary{calc} \usetikzlibrary{math} \setlength{\oddsidemargin}{5mm} \setlength{\evensidemargin}{5mm} \setlength{\textwidth}{16cm} \setlength{\topmargin}{-10.5mm} \setlength{\textheight}{22.5cm} \renewcommand{\arraystretch}{1.5} \begin{document} \numberwithin{equation}{chapter} \thispagestyle{empty} % without axes \begin{figure}[htb] \centering \begin{tikzpicture} \begin{axis}[scale only axis, xlabel near ticks, ylabel near ticks, xmin=-1, xmax=1, ymin=-1, ymax=1, xtick distance=0.5, ytick distance=0.5, grid=both] \end{axis} \end{tikzpicture} \label{fig:plot1} \end{figure} % with axes \begin{figure}[htb] \centering \begin{tikzpicture} \begin{axis}[scale only axis, xlabel near ticks, ylabel near ticks, xmin=-1, xmax=1, ymin=-1, ymax=1, xtick distance=0.5, ytick distance=0.5, grid=both, axis lines=middle] \end{axis} \end{tikzpicture} \label{fig:plot2} \end{figure} \end{document}

  • Error when trying to graph logarithm function in a different base
    by joseline on September 29, 2025 at 4:38 am

    I get this error when I try compile the function below ! Package PGF Math Error: Sorry, an internal routine of the floating point unit got an ill-formatted floating point number `1Y6.9305e-1]'. The unreadable part was near '1Y6.9305e-1]'. (in ' {ln(x)}/{ln(2)} '). See the PGF Math package documentation for explanation. Type H <return> for immediate help. ... l.46 ...-7:7,samples=100] { {ln(x)}/{ln(2)} } ; \documentclass[a4paper,10pt,oneside,onecolumn,final,tikz]{book} \usepackage[spanish,english]{babel} \linespread{1.1} \usepackage{tikz} \usetikzlibrary{arrows.meta} \usetikzlibrary {decorations.markings} \usepackage{pgfplots,tikz} \usetikzlibrary{patterns.meta} \usepackage[dvipsnames]{xcolor} \usepackage[svgnames]{xcolor} \begin{document} \begin{tikzpicture} \begin{axis}[grid=both, xmin=-5,xmax=5, ymin=-1,ymax=7, axis x line=middle, axis y line=middle, axis line style=->, height=13.0cm, restrict y to domain=-30:30, width=13.0cm, extra x ticks = {0}, % extra x tick labels={$\dfrac{1}{2}$}, xlabel={$x$}, ylabel={}, xtick={-4,...,4}, ytick={0,1,2,3,4,5,6,7}, ticklabel style={fill=white}, ] % node[pos=0.65,anchor=south west]{}; \addplot[no marks,ultra thick,purple,-] expression[domain=-7:7,samples=100] { {ln(x)}/{ln(2)} } ; \addplot[no marks,ultra thick,ForestGreen,-] expression[domain=-7:7,samples=100]{ {ln(x)}/{ln(5)} } ; \addplot[no marks,ultra thick,blue,-] expression[domain=-7:7,samples=100]{ {ln(x)}/{ln(1.3)} } ; \node at (axis cs:-3.3,5.5) [purple] {$f(x)=\log_{2}x$}; \node at (axis cs:-1.9,6.4) [ForestGreen] {$g(x)=\log_{5}x$}; \node at (axis cs:-2.7,1.65) [blue] {$h(x)=\log_{1.3}x$}; \end{axis} \end{tikzpicture} \end{document}

  • barplot with worldflags as ylabels
    by G. Bay on September 24, 2025 at 11:05 pm

    I would like to make a very minimalist bar plot, with different color bar for each country and their respective flag (worldflag if possible) instead of name. I have tried a few different things, but can't get it to work. Any ideas? Similar to this: MWE: \PassOptionsToPackage{usenames,dvipsnames,svgnames,table,cmyk,x11names}{xcolor} \documentclass[openright]{memoir} \setstocksize{23cm}{16cm} \setlength{\footskip}{35pt} \setlength{\parskip}{1em} \settrimmedsize{\stockheight}{\stockwidth}{*} \setlrmarginsandblock{2.5cm}{1.8cm}{*} \setulmarginsandblock{2.2cm}{2.7cm}{1} \usepackage{graphicx} \usepackage[T1]{fontenc} \usepackage[english,brazil]{babel} \usepackage[fontsize=11pt]{fontsize} \usepackage[]{fourier} \linespread{1.2} % \usepackage{mwe} \usepackage{lipsum} \usepackage{tikz} \usetikzlibrary{shadings, backgrounds, shadows.blur, fit} % \usepackage{worldflags} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=1.18} \usetikzlibrary{fillbetween} \usetikzlibrary{pgfplots.colorbrewer} \pgfplotsset{cycle list/Set1-5} \begin{document} \begin{tikzpicture} \pgfplotsset{ scale only axis, } % \vspace*{0.5em} %\hspace*{-2em} \begin{axis}[name=barplot, xbar, xmin=0, xmax=100, width=0.75\textwidth, height=12em, enlarge y limits=3, symbolic y coords={BR, IR, FR, DE}, ytick=data, xtick=\empty, xticklabels=\empty, yticklabels={,,}, axis lines=none, bar width=14pt, nodes near coords={\pgfmathprintnumber\pgfplotspointmeta\%}, nodes near coords align={horizontal}, yticklabel={ \raisebox{-0.5ex}{\tikz[scale=0.6,baseline]{\pic[local bounding box=flag] {worldflag={\tick}};}} } ] \addplot+[fill] coordinates {(07.4,BR)}; \addplot+[fill] coordinates {(39.4,IR)}; \addplot+[fill] coordinates {(59.3,FR)}; \addplot+[fill] coordinates {(76.3,DE)}; \end{axis} % \pic(de)[country=DE]{worldflag}; \pic(fr)[country=FR]{worldflag}; \pic(ir)[country=IR]{worldflag}; \pic(br)[country=BR]{worldflag}; \end{tikzpicture} \end{document}

  • Plotting functions without sampling artefacts
    by arctiq on September 24, 2025 at 3:28 pm

    I am interested in a generic technique to visualize functions in a quality appropriate for journal articles. Consider the function $$-\sqrt{\lvert x-\tan y \rvert}$$ over $[0,1]^2$. Tools like WolframAlpha can plot it beautifully with Plot3D[-Sqrt[Abs[x - Tan[y]]], {x, 0, 1}, {y, 0, 1}]: However, PGFplots produces unacceptable artefacts: \documentclass[border=10pt]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[view={30}{30}, domain=0:1] % Unacceptable plot of the desired function \addplot3[surf,shader=faceted interp]{-sqrt(abs(x-tan(deg(y))))}; % Desired shape of the ridge \addplot3[domain=0:pi/4, samples y=0] ({tan(deg(x))},{x},{0}); \end{axis} \end{tikzpicture} \end{document} Increasing the number of samples does not help as the slope approaches infinity near the $x=\tan y$ singularity. Postprocessing will not help as the sampling loses information. The black curve indicates the correct shape and position of the ridge compared to the actual result. I run into this all the time and know of no solution except drawing it by hand. Solutions involving external tools and LuaLaTeX are acceptable. GNUplot can not handle this either. I was unable to find a solution in the PGFplots documentation. AI tools provide no help either.

  • TikZ: Swapping axes in a three-dimensional coordinate system
    by Bigga on September 24, 2025 at 6:31 am

    I would like to create the following coordinate system with TikZ. German school books seem to deviate from (international?) conventions here; in any case, the axes need to be swapped, among other things. I use pgfplots for 2D plots, but I was unable to adjust the rotation of the axes here. I took the axis swap from this solution: https://texwelt.de/fragen/25321/tikz-koordinatenachsen-andern-im-3d-koordinatensystem/25322 I drew the coordinate system as shown here: https://tex.stackexchange.com/a/117175/238579 My interim result is as follows: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{shapes.misc} %\pgfplotsset{compat=1.18} \begin{document} \tikzset { Kreuz/.style = { cross out , draw , minimum size = 5pt , inner sep = 0pt , outer sep = 0pt } } \begin{tikzpicture}[ x={(0,0,1)}, y={(1,0,0)}, z={(0,1,0)}, z={(0,1cm)}, y={(1cm,0)}, >=latex, ] \draw[help lines, step=.5cm] (-3cm,-2cm) grid (5cm,5cm); \foreach \P/\s/\Pos in {(6,0,0)/x/below, (0,4.5,0)/y/right, (0,0,4.5)/z/above} \draw[-latex, thick] (0,0,0) -- \P node[\Pos, pos=1.01,inner sep=2pt]{$\s$}; \foreach \coo in {1,...,4} { \draw[thick] (xyz cs:y=-0.1pt,z=\coo) -- (xyz cs:y=0.1pt,z=\coo) node[right=8pt] {\coo}; \draw[thick] (xyz cs:z=-0.1pt,y=\coo) -- (xyz cs:z=0.1pt,y=\coo) node[below=8pt] {\coo}; } \foreach \coo/\label in {1.3/1,2.6/2,3.9/3,5.2/4} { \draw[thick] (xyz cs:y=-0.1pt,x=\coo) -- (xyz cs:y=0.1pt,x=\coo) node[right=4pt] {\label}; } \node[Kreuz, label=above:$S$] at (1.3,-1,3) {}; \end{tikzpicture} \end{document} I am satisfied with this so far. I find it unfortunate that I have to draw the coordinate system manually. I would be very interested in a more elegant solution, e.g., with pgfplots. However, I don't understand the scaling of the x-axis. It is actually shortened by a factor of sqrt(2). I determined the factor here by trial and error?!

  • 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?

  • Error with pgfplots and gnuplots on Mac TeXShop
    by lane-h-rogers on September 22, 2025 at 9:59 pm

    I am trying to compile a document using pgfplots and gnuplot. The relevant code block that I am trying to compile is: \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \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 gnuplot[raw gnuplot,mark=none,color=cyan] { plot [-10:10] real(sin(x)**besj0(x)) }; \end{axis} \end{tikzpicture} \end{document} I receive the error: ./test.tex:25: Package pgfplots Error: Sorry, the gnuplot-result file 'test.pgf-plot.table' could not be found. Maybe you need to enable the shell-escape feature? For pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>>gnuplot <file>.gnuplot' manually on the respective gnuplot file.. I'm completely new to gnuplot so I have no idea what the problem is. I am compiling via TeXShop on Mac. I installed gnuplot through the terminal. I have looked around at other answers advising to install gnuplot to a different location or enable shell-escape or write18 but have had no success. Does anyone know what could be going wrong?

  • Type gradient math text
    by Angelo Aliano Filho on September 20, 2025 at 7:11 pm

    how can I generate a math-text using gradient coloring, like this?

  • How to scale down a TikZ/PGFPlots figure with matching font size and good PNG quality
    by RiverSage on September 20, 2025 at 6:51 am

    I am trying to export a small TikZ/PGFPlots figure as a PNG using the standalone class with the convert option. My goal is to make the overall figure smaller (so that both the plot and the font size scale down consistently). Ensure that the exported PNG has good quality (no visible pixelation). Here is the full code I am working with: % Build engine and shell-escape (for PNG export) % !TEX TS-program = pdflatex % !TEX option = -shell-escape \documentclass[preview, border=2mm, convert=true]{standalone} \standaloneconfig{convert={density=600, size=1600x1600, outext=.png}} %%% Font packages \usepackage[LGR,T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage{microtype} \usepackage{upgreek} \usepackage[misc]{ifsym} \usepackage{xcolor} \definecolor{RGBpurple}{RGB}{112 48 160} %%% Maths and science packages \usepackage{amsmath,amsthm,amssymb} \usepackage{tikz,tkz-euclide,pgfplots} \usetikzlibrary{ calc, patterns, positioning, quotes, angles } \pgfplotsset{ compat=1.16, samples=200, clip=false, my axis style/.style={ axis x line=middle, axis y line=middle, legend pos=outer north east, axis line style={ ->, }, legend style={ font=\footnotesize }, label style={ font=\footnotesize, }, tick label style={ font=\footnotesize }, xlabel style={ at={ (ticklabel* cs:1), }, anchor=west, font=\footnotesize }, ylabel style={ at={ (ticklabel* cs:1) }, anchor=west, font=\footnotesize }, xlabel=\large{$x$}, ylabel=\large{$y$} }, } \tikzset{ >=stealth } %%% Tables and figures packages \usepackage{float} \usepackage{caption} \captionsetup{ format=plain, labelfont=bf, font=small, justification=centering } %%% Numbers and sets \newcommand{\E}{\mathrm{e}} %%% Title, author, date \title{Using the \texttt{tikzpicture} Environment for Drawing Graphs in \LaTeX} \author{\none} \date{\none} \begin{document} \nopagecolor %\maketitle \centering \begin{tikzpicture}[scale=0.5] \begin{axis}[ my axis style, width=6cm, scale only axis=true, thick, % width=\textwidth, % height=.5\textwidth, xtick distance=1, ytick distance=1, % xtick=\empty, % xticklabels=\empty, % ytick=\empty, % yticklabels=\empty, ymin=-2.5, ymax=4.5, xmin=-4.5, xmax=4.5, ] \addplot[ domain=-2:2, restrict y to domain=-4:4, thick, blue, - ] {x}; \end{axis} \end{tikzpicture} % \end{document} Here is the png I get

  • Bug in pgfplots? "xticklabels" considers order in csv while "symbolic x coords" does not
    by nopx on May 19, 2025 at 11:47 am

    For barplots: I found that xticklabels does considers the order in the csv files while symbolic x coords` does not. This leads to situations where incorrect data is displayed. That is the ticks do not appear for the correct data. In the below example it shows the value two for metric C, even though the value in the csv is three. What am I doing wrong? How to fix this? Here is a minimal example: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \iftrue % If true, the displayed data is wrong! The alternative is just two rows flipped, see below. \begin{filecontents*}{data.csv} ,methodA,methodB,methodC metricA,1,1,1 metricC,3,3,3 metricB,2,2,2 \end{filecontents*} \else \begin{filecontents*}{data.csv} ,methodA,methodB,methodC metricA,1,1,1 metricB,2,2,2 metricC,3,3,3 \end{filecontents*} \fi \begin{document} \pgfplotstableread[col sep = comma]{data.csv}\table \begin{tikzpicture} \begin{axis}[ ybar, symbolic x coords={metricA,metricB,metricC}, xticklabels={A,B,C}, xtick=data, ] \addplot [fill=red ] table [x index=0, y=methodA] {\table}; \addplot [fill=blue ] table [x index=0, y=methodB] {\table}; \addplot [fill=green] table [x index=0, y=methodC] {\table}; \end{axis} \end{tikzpicture} \end{document} If we extend the example to 6 different rows, it become even more confusing. \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \begin{filecontents*}{data.csv} ,methodA,methodB,methodC A,1,1,1 B,2,2,2 D,4,4,4 E,5,5,5 F,6,6,6 C,3,3,3 \end{filecontents*} \begin{document} \pgfplotstableread[col sep = comma]{data.csv}\table \begin{tikzpicture} \begin{axis}[ ybar, symbolic x coords={A,B,C,D,E,F}, xtick=data, xticklabels={A,B,C,D,E,F}, ] \addplot [fill=red ] table [x index=0, y=methodA] {\table}; \addplot [fill=blue ] table [x index=0, y=methodB] {\table}; \addplot [fill=green] table [x index=0, y=methodC] {\table}; \end{axis} \end{tikzpicture} \end{document} The xticklabels seems to be completely confused about the labels. I don't see any pattern anymore ... Please, does anyone understand this?

  • pgfplots - clipping on different layers
    by mm96 on January 3, 2025 at 12:47 pm

    I don't understand how clipping on different layers works. In the example, I tried to clip the grid and the function +x, but it seems the clipping always takes place on the main layer: \documentclass{scrartcl} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \pgfplotsset{set layers=standard} \begin{axis}[ xmin=-3, xmax=3, ymin=-3, ymax=3, axis lines = center, enlargelimits={abs=0.4cm}, grid=both, grid style = { on layer = axis grid, }, ] \addplot[on layer = axis grid] {x}; \addplot [on layer = main] {-x}; \clip [on layer = axis grid](-3,-3) rectangle (3,3); \end{axis} \end{tikzpicture} \end{document} I got the idea from percusses answer from this question (don't enlarge grid) but couldn't bring it to work even when trying "execute at begin" in different combinations. Thanks for your advice!

  • Questions about pgfplot (ticks position, position of axis label, aspect ratio, etc)
    by Dimitris on September 26, 2024 at 3:11 pm

    I used the following code to plot a sequence: \begin{tikzpicture} \begin{axis}[ title={Graphique de la suite \(u_n = 3n^2 - 5\)}, %samples=60, domain=0:5, xmax=5.5, xmin = -0.25, restrict y to domain=-20:80, ymax=80, ymin=-20, axis lines=left, % y=0.5cm/15, % x=0.5cm, grid=both, axis lines=middle, % Pour avoir des axes au milieu xtick={0,...,5}, compat=newest, ytick={-15,0,15,...,75}, x tick label style={below right}, y tick label style={above left}, compat=newest, xlabel=$n$, xlabel style={at={(1,0.15)}, anchor=north, above right}, ylabel=$u_n$, ylabel style={rotate=-90,at={(0.05,1)}, anchor=south} ] % Courbe de la suite \addplot[color=blue, thick] coordinates { (0,-5)(1,-2)(2,7)(3,22)(4,43)(5,70) }; % Points marqués en rouge \addplot[only marks, mark=*, mark options={scale=0.75, color=red}] coordinates { (0,-5)(1,-2)(2,7)(3,22)(4,43)(5,70) }; \end{axis} \end{tikzpicture} I get the following plot. I have a few questions regarding the customization of axis labels and ticks in a TikZ/pgfplots environment: Centering Axis Labels: I want the axis labels to be exactly centered on their respective axes. Currently, I'm doing this manually through trial and error, but I assume there’s a more straightforward setting to achieve this automatically. Is there a simple way to center them properly? Tick Placement: How can I adjust the ticks so that they appear closer to their respective axes? I’d like the ticks to be positioned along the axis lines. Displaying Zero Ticks: I’m trying to make sure the tick at zero is visible, but currently, it doesn’t show up. How can I ensure that the ticks at zero are displayed on both axes? Square Axes: How can I force both axes to have the same scale, so that the units on the 𝑥-axis and 𝑦-axis are equal, resulting in a square plot? Thanks a lot for your help!

  • Cycling Line Colours with Pgfplot Cubic Spline Patches
    by Freddie Witherden on September 5, 2024 at 6:30 pm

    Consider the following snippet: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepgfplotslibrary{colorbrewer, patchplots} \begin{document} \begin{tikzpicture} \begin{axis}[cycle list/Set2] \addplot+[patch, patch type=cubic spline, point meta=none, red] coordinates { (-1,-1) (1,1) (-1/3,{(-1/3)^3}) (1/3,{(1/3)^3}) }; \end{axis} \end{tikzpicture} \end{document} which is based off the cubic spline patch example in the PGFPLOTS manual. As expected it produces a red curve. However, I am having trouble changing the colour to be one from a set. For example swapping red for index of colormap=2 of Set2 causes the line to revert to black. What is the correct means of applying a uniform colour from a colour map to all of the patches?

  • pgf import in LaTeX not working due to matplotlib axes font
    by L_physics on May 20, 2024 at 1:12 pm

    I was plotting as usual and then after saving one of my plots as a pgf and then compiling LaTeX it didn't work anymore. As far as I'm aware of, I didn't change anything it just so happen to top working. The code I'm using to make an example plot is the following: import matplotlib . pyplot as plt import numpy as np from pathlib import Path import matplotlib .cm as cm import tikzplotlib import matplotlib as mpl mpl.rcParams['mathtext.fontset'] = 'cm' # Latex font mpl.rcParams['font.family'] = 'serif' mpl.rcParams['font.serif'] = ['cmr10'] mpl.rcParams['axes.formatter.use_mathtext'] = True # Erzeuge eine Liste von x-Werten x = np.linspace(-5, 10, 100) a= [2,8,8,2] b=[2,2,8,2] U_1=2 U_2=8 I_1=2 I_2=8 # Berechne die entsprechenden y-Werte für die Funktion y = x y = x # Plotte die Funktion plt.plot(x, y) plt.plot(a,b, color = 'crimson', marker='', linestyle='dashed') plt.plot(U_1,I_1, color = 'green', marker='x', linestyle='',label='$(U_{1}, I_{1})$', markersize=14) plt.plot(U_2,I_2, color = 'orange', marker='x', linestyle='',label='$(U_{1}, I_{2})$', markersize=14) plt.plot(U_2,I_1, color = 'purple', marker='x', linestyle='',label='$(U_{2}, I_{2})$', markersize=14) # Beschriftungen für die Achsen hinzufügen plt.xlabel('$I$ / arbitrary units') plt.ylabel('$U$ / arbitrary units') # Titel für den Plot hinzufügen plt.title('Beispiel Fit') plt.legend(loc='upper left') # Grid hinzufügen plt.grid(True) # Den Plot anzeigen plt.savefig('example.pgf', format='pgf', bbox_inches='tight', pad_inches = 0) plt.show() I tried multiple things and I'm pretty sure that the problem is in the commands mpl.rcParams['font.serif'] = ['cmr10'] mpl.rcParams['axes.formatter.use_mathtext'] = True Sure I can commen them out but then (more bovious for other plots) the axes will be in a weird font and if I have a different, let's say logarithmic scaling, it wont look like 10^{-21} like in latex and the font is different as well. The error codes in Latex which I'm getting are ! Undefined control sequence. <recently read> \mathdefault l.109 ...\catcode`\%=\active\def%{\%}$\mathdefault {\ensuremath{-}4}$}}% The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. ! Undefined control sequence. <recently read> \mathdefault l.147 ...\catcode`\%=\active\def%{\%}$\mathdefault {\ensuremath{-}2}$}}% The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. ! Undefined control sequence. <recently read> \mathdefault l.185 ...\catcode`\%=\active\def%{\%}$\mathdefault {0}$}}% The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. ! Undefined control sequence. <recently read> \mathdefault l.223 ...\catcode`\%=\active\def%{\%}$\mathdefault {2}$}}% The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. ... I also posted this question here https://stackoverflow.com/q/78504075/2777074

  • How can I make a violin plot in PGFPlots
    by hpekristiansen on October 25, 2022 at 2:05 pm

    Taking the data from this question: Spread the dots in boxplot in pgfplots How can I make a violin plot.

  • Alignment of pgfplots inside subfloats when using tikzplotlib
    by Marvin Noll on December 4, 2020 at 10:58 pm

    I'm using the tikzplotlib code below to generate two Plots. I then place them in two subfloats. As you can see in the final latex output, the figure looks rather ugly with the two plots differently sized and not aligned. What can i do to achieve the same size of the plots and to align them properly. Maybe worth noting, i have several of these figures with multiple subfloats in my document. Python: import matplotlib.pyplot as plt import tikzplotlib import numpy as np x1=np.arange(0,10)*10e9 x2=np.arange(0,1000) y1=np.random.randn(1,len(x1))[0] y2=0.01*x2*np.random.randn(1,len(x2))[0] KIT_green=(0/255,150/255,130/255) KIT_blue=(70/255,100/255,170/255) plt.figure() plt.plot(x2,y2,label="second trace",color=KIT_green) plt.xlabel(r"Time $t$ (in \si{\milli\second})") plt.ylabel(r"Amplitude $S_{11}$ \\ (some measurement) \\ (and another meaningless line) (in \si{\volt})"); tikzplotlib.save("subfigs_left.tikz",extra_axis_parameters=["ylabel style={align=center}"],axis_width="5cm",axis_height="5cm") plt.figure() plt.plot(x1,y1,label="first trace",color=KIT_blue) plt.xlabel(r"Time $t$ (in \si{\milli\second})") plt.ylabel(r"Amplitude $S_{11}$, $S_{35}$ (in \si{\volt})"); tikzplotlib.save("subfigs_right.tikz",extra_axis_parameters=["ylabel style={align=center}"],axis_width="5cm",axis_height="5cm") LaTeX: \documentclass[11pt]{article} \usepackage[utf8]{inputenc} \usepackage{graphicx} \usepackage{subfig} \usepackage{siunitx} \usepackage{tikz} \usepackage{pgfplots} \usepackage{tikzscale} \begin{document} \begin{figure} \centering \subfloat[Plot 1: this shows this]{\includegraphics[width=0.4\textwidth]{subfigs_left.tikz}} \qquad \subfloat[Plot 2: and this shows that. But this explanation is quite long. blablabla]{\includegraphics[width=0.4\textwidth]{subfigs_right.tikz}} \caption{Two plots} \label{fig:subfig} \end{figure} \end{document}

  • 3d intersections
    by Blooment on November 7, 2020 at 7:47 pm

    As exercise, I'm trying to draw the intersection of the prism [0,2] x [0,4] x [0,6], and the plane x + y + z = 5. My result is: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture}[x={(-0.45cm,-0.385cm)},y={(1cm,-0.1cm)},z={(0,1cm)}] \draw [->] (0,0,0) -- (6,0,0) node [below left] {$x$}; \draw [->] (0,0,0) -- (0,6,0) node [right] {$y$}; \draw [->] (0,0,0) -- (0,0,6) node [right] {$z$}; \filldraw [thick, orange, fill opacity=0.3] (0,0,5) -- (0,4,1) -- (1,4,0) -- (2,3,0) -- (2,0,3) -- cycle; \filldraw [thick, blue, fill opacity=0.2] (2,3,0) -- (2,0,3) -- (5,0,0) -- cycle; \filldraw [thick, blue, fill opacity=0.2] (1,4,0) -- (0,5,0) -- (0,4,1) -- cycle; \filldraw [thick, orange, fill opacity=0.3] (2,3,0) -- (2,0,0) -- (2,0,3) -- cycle; \filldraw [thick, orange, fill opacity=0.3] (1,4,0) -- (0,4,0) -- (0,4,1) --cycle; \end{tikzpicture} \end{document} I have some questions now: I think there's a lot of code just to represent an easy mathematical volume as [0,2] x [0,4] x [0,6]. Is there some more efficient way of drawing it? Do I need to calculate the intersections by hand and then represent it? Or is there any direct method? How can I obtain the same result by using an axis environment and \addplot commands instead of \draw? I've tried but I'm new to \addplot3 and I'm having trouble with axis position (view={}{}), colormap has not a homogeneus color, the surface has a grid that difficults the understanding of the picture and I have the same doubt on intersections, Do I need to calculate them by hand? Full prism is: \draw [fill=orange, fill opacity=0.3] (0,0,6) -- (2,0,6) -- (2,4,6) -- (0,4,6) -- cycle ; \draw [fill=orange, fill opacity=0.3] (2,0,0) -- (2,0,6) -- (2,4,6) -- (2,4,0) -- cycle ; \draw [fill=orange, fill opacity=0.3] (2,4,0) -- (0,4,0) -- (0,4,6) -- (2,4,6) -- cycle ;

  • Plotting function ℝ² →ℝ with pole at (0,0) smoothly
    by Wizard of Math on May 30, 2020 at 1:56 pm

    I would like to plot the function f: ℝ² →ℝ, definited by f(x,y)=(xy)/(x^2+y^2). But the following problem comes up: At (0,0) the function is not continous and therefore it looks kind of jagged. To solve this problem i could force the function to input specific points but i can't find it anywhere an don't know if that is even possible. Code: \begin{tikzpicture}[] \begin{axis}[axis lines=center, axis on top, xtick=\empty, ytick=\empty, ztick=\empty, xrange=-2:2, yrange=-2:2 ] % function \addplot3[domain=-2:2,y domain=-2:2,colormap/viridis,surf,opacity=0.5,samples = 55] {(x*y)/(x^2+y^2)}; \end{axis} \end{tikzpicture} How do i make this function look smooth? Any help would be greatly appreciated 🙂 (Just increasing the Samples doesnt do that much, and I run into the following error: TeX capacity exceeded, sorry [main memory size=3000000])

  • Documentation of additional keys or commands when using TikZ or pgfplots in beamer presentations
    by Diaa on September 25, 2019 at 12:51 pm

    After going through this answer, I wondered if there is a documentation of the available keys that can be used as options when drawing using TikZ or pgfplots. For example, the key alt in \node[alt={<2>{... I didn't find it documented in either manual of TikZ or beamer. So, where can I find good documentation of all the additional available keys that can be used when drawing using TikZ or pgfplots?

  • Pgfplot: create own marker or fill marker with pattern (legend)
    by jlk on September 14, 2016 at 12:42 am

    I have a hatched area and would like to create a marker with same hatched filling for the legend. But it seems like even setting just a marker doesn't work -- what's going wrong? And it would be greatif some could explain me how to fill the marker with a hatching/pattern. \documentclass[border=4pt]{standalone} \usepackage{pgfplots} \pgfplotsset{ compat=1.12 } \usetikzlibrary{patterns} \begin{document} \begin{tikzpicture} \begin{axis}[ legend style={cells={align=left}} ] \addplot {rnd}; \addlegendentry{a}; \addplot [ draw=none, postaction={pattern = north east lines, pattern color=red}] coordinates { (0, 1) (0, 0) (2, 0) (2, 1) }; \addlegendimage{red, mark=square}%pattern = north east lines, pattern color=red \addlegendentry{b}; \end{axis} \end{tikzpicture} \end{document}

  • Differential Equation direction plot with pgfplots
    by Alexander Mathiasen on October 16, 2013 at 11:05 am

    In earlier thread Jake provided some code whom successfully draws the following differential equations in the range [0; 1] dy/dx=2*x dy/dx=x*sqrt(x) See: How to draw slope fields with all the possible solution curves in latex I have not been able to determine how to change the range to [-1; 1] for both dimensions. My attempt xmin=-1.1, xmax=1.1, % Axis limits ymin=-1.1, ymax=1.1, domain=-1:1, y domain=-1:1, Also, I had some trouble with the notation for a differential equation that consists of y, example (dy/dx=x^2+y^2-1). My attempt: declare function={f(\x) = \x^2 + f(\x)^2 - 1;}