pgfplots
- pgfplots warning when input starts with equal digitsby jlab on November 8, 2026 at 2:28 pm
I'm plotting thermodynamics data with pgfplots. I get a strange warning when a value begin with 55. For example: \addplot table[x index=3,y index=1, col sep=comma]{ 311.00, 100.00, 55.463, 0.018030 } ; gives Missing character: There is no . (U+002E) in font nullfont! Missing character: There is no 4 (U+0034) in font nullfont! Missing character: There is no 6 (U+0036) in font nullfont! Missing character: There is no 3 (U+0033) in font nullfont! If I replace 55.463 with 550 I get Missing character: There is no 0 (U+0030) in font nullfont! But there is no warning if 55.463 is replaced by 5.463 54.463 56.463 Any idea to explain this strange behaviour? Compilable example: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ ,xmin = {0} ,xmax = {0.02} ,ymin = {90} ,ymax = {300} ] %% Warnings: %% Missing character: There is no . (U+002E) in font nullfont! %% Missing character: There is no 4 (U+0034) in font nullfont! %% Missing character: There is no 6 (U+0036) in font nullfont! %% Missing character: There is no 3 (U+0033) in font nullfont! %% \addplot table[x index=3,y index=1, col sep=comma]{ 311.00, 100.00, 55.463, 0.018030 } ; %% Replace 55.463 by 550: %% Missing character: There is no 0 (U+0030) in font nullfont! \addplot table[x index=3,y index=1, col sep=comma]{ 311.00, 100.00, 550, 0.018030 } ; %% Replace 55.463 by 5.463: no warnings \addplot table[x index=3,y index=1, col sep=comma]{ 311.00, 100.00, 5.463, 0.018030 } ; %% Replace 55.463 by 54.463: no warnings \addplot table[x index=3,y index=1, col sep=comma]{ 311.00, 100.00, 54.463, 0.018030 } ; %% Replace 55.463 by 56.463: no warnings \addplot table[x index=3,y index=1, col sep=comma]{ 311.00, 100.00, 56.463, 0.018030 } ; \end{axis} \end{tikzpicture} \end{document} Bug report I filled a bug report for that: https://github.com/pgf-tikz/pgfplots/issues/532
- LUA survey failed: Function is undefinedby Manuel Schmidt on October 8, 2026 at 3:46 pm
I switching from vscode to vimtex and a document which complied (with lualatex) without errors still compiles, but I get the following error and vimtex thinks compilation failed which causes the viewer not updating, etc. LUA survey failed: ...tex/generic/pgf/libraries/luamath/pgf/luamath/parser.lua|105 error| Function 'quadfnc' is undefined (did not find pgfluamathfunctions.quadfnc (looked into pgfluamathfunctions.stringToFunctionMap)). Use \pgfplotsset{lua debug} to see more. I have the function quadfnc declared with pgfmath, but not pgfluamath: \pgfmathdeclarefunction{quadfnc}{2}{% \pgfmathparse{2*(#1)^2+(#2)^2 + #1*#2-6*#1-5*#2}% } I am calling it like \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \pgfmathdeclarefunction{quadfnc}{2}{% \pgfmathparse{2*(#1)^2+(#2)^2 + #1*#2-6*#1-5*#2}% } \begin{document} \begin{tikzpicture} \begin{axis}[ ] \addplot3[surf,samples=10] {quadfnc(x,y)}; \end{axis} \end{tikzpicture} \end{document} As said, the document complies and I get a perfectly fine pdf. However vimtex treats it like a real error and basically aborts all further processing. Edit: The error seems to occur only when \pgfplotsset{compat=1.18} is set. This seems to enable the lua backend.
- How to name a string variable inside a \foreach loop using the loop variableby Plum Rapson on October 4, 2026 at 3:42 pm
I am trying to simplify my document typing for schoolwork. For ODEs, we are asked to show multiple possible solutions for a given differential equation. I have been using TikZ, pgfplots, and a dash of audacity to place multiple functions on the same graph, changing either the value of y_0 or C or both to show different function outcomes. However, this takes up a lot of space and time, so I am hoping that I could define a new command to repeatedly \addplot with slightly different functions. Here's what I have so far, including the page setup and relevant preamble for a sanity check: \documentclass[12pt]{article} \usepackage{geometry} %I have my page set to weird sizes and small margins \usepackage{pgfplots} \usepackage{tikz} \usetikzlibrary{shapes.geometric,arrows.meta,calc,pgfplots.external} \pgfplotsset{compat=1.18} \usepackage{xstring} \newcommand{\addmultiplot}[3][2]{ %{sample}{variable}{equation} where sample is a number %determined by my own organization, variable is %the character variable to be changed, equation is %formatted exactly as it would in \addplot \IfEqCase{#1}{ {0.1}{ \def\a{-0.9} \def\b{-0.1} \def\c{0.1} \def\d{0.4} \def\e{0.75} \foreach \x in {\a, \b, \c, \d}{ \StrSubstitute{#3}{#2}{\x}[\NAME] \def\nums{\a, \b, \c, \d, \e} %%%% Haven't been able to test, want this to give me \nums = {-0.9, -0.1, 0.1, 0.4, 0.75} } } {2}{ \def\a{-10} \def\b{-5} \def\c{2} \def\d{5} \def\e{10} \foreach ... } } . . . [] }; \foreach \v in {\nums} {\addplot{\NAME}};} \begin{document} \begin{tikzpicture} \begin{axis}[xticks =\empty, yticks= \empty] \addmultiplot{2}{C}{3*(C)/((C) + exp(3*x^2)*(3 - (C)))}; \end{axis} \end{tikzpicture} \end{document} What I am struggling with is [\NAME], Where I would want something like eq\x so that the last line of the command sees nums as {-0.9, -0.1, 0.1, 0.4, 0.75} and outputs \addplot{eq-0.9}; \addplot{-0.1}; etc. Maybe trying to have the negative sign be a part of it would be a problem, but I haven't even gotten there yet. At first I had [eq\x], but it gave me a \def issue "please don't put \def cs {...} use \def\cs{...}" on the line where I called \addmultiplot, and after trimming things down and making sure all the numbers were going into clearly defined variables, I'm left with assuming it involves the names of my equations, but surely [\eq\x] would not result in the first string later being referred to by "eq-0.9" so that when the final \foreach looks at \nums and pulls -0.9, \addplot can receive the equation that has C replaced with -0.9.
- use newline in f:writeby flawr on September 28, 2026 at 10:08 pm
I'd like to create a data file using lua in LuaTeX that I can reuse e.g. using pgfplots. But currently I'm stuck printing multiple lines as it seems the "\n" will always get interpreted as a TeX command and not as a newline. How would we correctly do that in this document? \documentclass{article} \usepackage{pgfplots} \usepackage{luacode} \begin{document} \begin{luacode} local f = io.open("data.txt", "w") for x = 0, 10, 0.5 do local y = math.sin(x) f:write(x .. " " .. y .. "\n") end f:close() \end{luacode} \begin{tikzpicture} \begin{axis} \addplot table {data.txt}; \end{axis} \end{tikzpicture} \end{document}
- Tangential curve labels with 1D force-based collision avoidance along paths in pgfplotsby cjorssen on May 17, 2026 at 8:44 pm
I am trying to implement a dynamic labeling system for multiple curves within a pgfplots axis environment. The goal is to have curve labels that are both tangential (sloped) to their respective paths and capable of avoiding collisions by utilizing a 1D force-based relaxation mechanism to repel each other along the curves' domains. My Understanding of pgfplots Internals From what I understand of pgfplots internals, and please correct me if my assumption is flawed, the package operates on a deferred drawing (or accumulation) model, conceptually quite similar to how matplotlib handles figures in Python. It seems to split its workflow into distinct steps: A Survey Phase where it reads \addplot data, accumulates coordinates in memory, and computes the global axis limits. A Visualization Phase triggered at \end{axis} where it maps data coordinates to physical dimensions and emits the actual TikZ paths and nodes. Based on this understanding, it feels like the ideal place to inject a label-relaxation algorithm would be right between these two phases (perhaps using hooks like before end axis), after the data is parsed but before the final typesetting occurs. The Technical Bottleneck: The Node Bounding Box Dilemma The core difficulty I am facing is a classic "chicken-and-egg" problem: To know the dimensions (width, height, depth) of a label's bounding box for collision detection, TeX must first typeset the text into a box. However, we cannot definitively position or rotate that node along the path until the force-based algorithm has computed the final, relaxed $t$ parameters for all curves. If a LuaLaTeX-based approach is required to handle the physics/loop, I am completely open to it. But I am unsure how to elegantly pass TeX box dimensions into Lua, or how to query the generated curve paths before the rendering phase. Minimal Working Example (Current State) Here is a basic MWE where the labels are sloped but completely overlap: \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ domain=0:3.5, restrict y to domain = 0:10, samples=100, axis lines=left ] % Curve 1 \addplot[blue, thick] {x^2} node[pos = 0.2, sloped] {Function $f(x)$}; % Curve 2 \addplot[red, thick] {1/x} node[pos = 0.8, sloped] {Function $g(x)$}; \end{axis} \end{tikzpicture} \end{document} Tentative Logic / Pseudo-code (Force-Based Relaxation) Ideally, the macro or Lua script would perform a spring-embedder / force-directed approach constrained to 1D path coordinates: # Pre-computation phase for each label L_i: Typeset L_i into a temporary TeX box to get its dimensions (W_i, H_i) # Force-directed loop while system_not_in_equilibrium and max_iterations_not_reached: Initialize forces F_i = 0 for all labels for each curve i with label L_i: 1. Get baseline position P_i = curve_i(t_i) 2. Compute tangent angle theta_i at t_i 3. Construct Label Bounding Box B_i (using W_i, H_i) at P_i rotated by theta_i for each pair of labels (L_i, L_j): if Intersect(B_i, B_j): # Compute repulsive force based on overlap magnitude force_magnitude = calculate_repulsive_force(B_i, B_j) # Project force along the 1D direction of the respective curves F_i = F_i - force_magnitude F_j = F_j + force_magnitude # Update positions using a small step size (damping) for each label L_i: t_i = t_i + alpha * F_i ConstraintToValidDomain(t_i) Questions & Directions Is my mental model of the pgfplots accumulation process accurate enough to build upon, or am I missing a fundamental constraint of the package architecture? Is there an existing package or experimental snippet that already handles force-based label placement or relaxation algorithms along TikZ paths? If doing this via LuaLaTeX, what is the cleanest way to intercept the path coordinates generated by pgfplots and pass the TeX box dimensions to a Lua-based physics loop? Any pointers, conceptual corrections, or architectural advice would be highly appreciated. Real-World Use Case (Thermodynamic Diagrams) To provide some concrete context on why this automation is so critical for my workflow, here is a screenshot of the type of complex diagram I am currently generating (with luatex, FFI and the CoolProp shared library). It is a pressure-enthalpy (p-h) diagram widely used in refrigeration and chemical engineering, plotted in the (p, log h) plane for a pure substance. As you can see, the visual density is extremely high because it overlays several distinct families of isolines crossing each other: Isotherms (constant temperature) Isentropes (constant entropy) Isochores (constant specific volume) Vapor quality lines / isotitres (constant dryness fraction) Manually hardcoding and fine-tuning the pos parameter for dozens of labels across these intersecting families of curves is completely unmanageable—especially since the curves shift dramatically depending on the thermodynamic properties of the fluid being modeled. Having a generalized, tangential, force-directed algorithm to let these labels dynamically find their equilibrium along their respective paths would be an absolute game-changer for rendering complex engineering charts natively in pgfplots.
- Use "plot" inside a \draw path in tikzby flawr on April 30, 2026 at 5:36 pm
Is there a way to continue a path we draw using \draw with a plot, just as we do for instance also with arc or similar commands? In the example below I have a straight line, but I'd like the plot to append directly to that line, as indicated by the red dots. I can of course do that e.g. with plot[shift={(1,1)},...], but that means that I have to repeat that second coordinate in the path, which makes it again more cumbersome to use if we want to change something later (and the second straight line segment then points to the original endpoint without the shift). So this is more a question about "ergonomically" using this plot command inside other paths. E.g., I also like using the ++ syntax to precisely extend a path a certain distance horizontally, without having to repeat the previous y-coordinate, and I was wondering whether there is something similar we can do with the plot command inside such a path. \documentclass{standalone} \usepackage{tikz} \usepackage{xcolor} \usepackage{pgfplots} \pgfplotsset{compat=1.17} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture}[domain=0:4] \draw[black!10!white, dashed] (0, 0) grid (4, 2); \draw (0, 1) -- (1, 1) node[left] {} plot[domain=0:1, samples=100] function{sin(6.3*x)} node[right] {} -- ++(1, 0); \end{tikzpicture} \end{document}
- plot the implicit function using Luaby 青山漫步 on April 14, 2025 at 8:23 am
I want to use the built-in Lua language in LuaLaTeX to plot the implicit function x*y^2+2*x^3*y^3-y-1=0. My idea is to plot the points within the rectangular region [−5,5]×[−5,5] that satisfy the above equation. Here is my code, but I didn't get any output. Can you tell me where I went wrong? % !TEX program = Lualatex % !Mode:: "TeX:UTF-8" \DocumentMetadata{} \documentclass[12pt]{article} \usepackage{luacode} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{luacode} function mefun (x,y) return x*y^2+2*x^3*y^3-y-1 end function Imfun(n) --[-5,5]*[-5,5] for i=0, n do ti=-5.0+10.0*i/n for j=0, n do tj=-5.0+10.0*j/n temp=mefun(ti,tj) if (math.abs(temp))<1e-3 then tex.print(string.format('(%2.5f, %2.5f)', ti, tj)," \\par") else break end end end end \end{luacode} \begin{document} \begin{tikzpicture} \begin{axis}[xlabel=$x$, ylabel=$y$] %\addplot coordinates{ \addplot[cyan,smooth,line width=1.0pt] coordinates{ \luadirect{ Imfun(100) } }; \end{axis} \end{tikzpicture} \end{document}
- genus-2 torus using tikz-3dplotby userא0 on March 12, 2025 at 12:41 pm
I'm attempting to create a 3D plot of a connected sum of two tori in LyX using the tikz-3dplot package, aiming for a visual representation similar to the image linked here Link Here. I have seen similar plots online, generated by Alternative packages (most of the are similar to the picture in Wikipedia under "Connected Sum"), In which I have no interest. Searching the internet and with the help of some AI engines, I was able to come up with this \documentclass[margin=5pt]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture}[] \begin{axis}[ hide axis, view={40}{60}, ] % Hyperboloid Tube (hyperboloid of one sheet) % Parameters: a = 1.5, c = 5*sqrt(2) % Here: the PGFPlots parameter "x" is used for t, and "y" for theta. \addplot3[ surf, faceted color=black, fill=none, samples=20, samples y=30, domain=-1:1, % t from -1 to 1 domain y=0:2*pi, % theta from 0 to 2pi z buffer=sort, ] ( { (1/(sqrt(2))) * ( 1.5*sqrt(1+x*x)*cos(deg(y)) + 4*sqrt(2)*x ) }, { (1/(sqrt(2))) * ( -1.5*sqrt(1+x*x)*cos(deg(y)) + 4*sqrt(2)*x ) }, { 1.5*sqrt(1+x*x)*sin(deg(y)) } ); % First Torus (centered at (-5,-5,0)) \addplot3[ surf, faceted color=black, fill=none, samples=22, samples y=30, domain=0:2*pi, domain y=0:2*pi, z buffer=sort, ] ({ (5+2*cos(deg(x)))*cos(deg(y))-7 }, { (5+2*cos(deg(x)))*sin(deg(y))-7 }, { sin(deg(x)) }); % Second Torus (centered at (5,5,0)) \addplot3[ surf, faceted color=black, fill=none, samples=22, samples y=30, domain=0:2*pi, domain y=0:2*pi, z buffer=sort, ] ({ (5+2*cos(deg(x)))*cos(deg(y))+7 }, { (5+2*cos(deg(x)))*sin(deg(y))+7 }, { sin(deg(x)) }); \end{axis} \end{tikzpicture} \end{document} which after compiling looks like this I'm not sure how to get these three surfaces to look like they're all part of one piece, besides maybe trying to plot the whole surface as a graph of a single function, which I also don't know how to do. Any help or ideas on either way would be awesome!. Thanks The full latex code: % Preview source code %% LyX 2.4.1 created this file. For more info, see https://www.lyx.org/. %% Do not edit unless you really know what you are doing. \documentclass[english,hebrew,no-math]{extarticle} \usepackage{amsmath} \usepackage{amsthm} \usepackage{fontspec} \setmainfont[Mapping=tex-text]{Hadasim CLM} \setsansfont[Mapping=tex-text]{FreeSerif} \setmonofont{FreeMono} \usepackage[a4paper]{geometry} \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2cm,rmargin=2cm,headheight=2cm,headsep=2cm} \usepackage{setspace} \doublespacing \usepackage[pdfusetitle, bookmarks=true,bookmarksnumbered=false,bookmarksopen=false, breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false] {hyperref} \makeatletter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. \numberwithin{equation}{section} \@ifundefined{date}{}{\date{}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. \PassOptionsToPackage{all,color}{xy} \usepackage{tikz} \usepackage{tikz-3dplot} \usetikzlibrary{shapes.geometric} \usetikzlibrary{3d,calc} \usetikzlibrary{matrix,shapes} \usetikzlibrary{arrows.meta} \usetikzlibrary{decorations.markings} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usepackage{faktor} \usepackage{graphicx, nicefrac} \usepackage[all]{xy} % Define a command to reflect box \let\rfb\reflectbox \newcommand{\uglyfrac}[2]{\scalebox{1.35}{\rfb{\nicefrac{\raisebox{0.7ex}{\rfb{#1}}}{\raisebox{-0.7ex}{\rfb{#2}}}}}} \newcommand{\muglyfrac}[2]{\uglyfrac{\ensuremath{#1}}{\ensuremath{#2}}} \usepackage{xcolor} \hypersetup{ colorlinks, linkcolor={red!24!blue}, citecolor={blue!75!black}, urlcolor={blue!75!black} } \usepackage{fancyhdr} \pagestyle{fancy} \usepackage{bbm} \usepackage{xfrac} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \newcommand\bquotient[2]{ \mathchoice {% \displaystyle \text{\lower1ex\hbox{$#2$}\Big/\raise1ex\hbox{$#1$}}% } {% \textstyle #1\,/\,#2 } {% \scriptstyle #1\,/\,#2 } {% \scriptscriptstyle #1\,/\,#2 } } \newcommand\Bquotient[2]{ \mathchoice {% \displaystyle \text{\lower1ex\hbox{$#2$}\Bigg/\raise1ex\hbox{$#1$}}% } {% \textstyle #1\,/\,#2 } {% \scriptstyle #1\,/\,#2 } {% \scriptscriptstyle #1\,/\,#2 } } \newcommand\Anquotient[3][-22]{% #1 is the optional angle, default is 45 \mathchoice {% \displaystyle \text{\lower0.8ex\hbox{$#3$}\rotatebox{#1}{$\big/$}\raise0.8ex\hbox{$#2$}}% } {% \textstyle #2\rotatebox{#1}{/}#3 } {% \scriptstyle #2\rotatebox{#1}{/}#3 } {% \scriptscriptstyle #2\rotatebox{#1}{/}#3 } } \newcommand\Abquotient[3][-22]{% #1 is the optional angle, default is 45 \mathchoice {% \displaystyle \text{\lower0.8ex\hbox{$#3$}\rotatebox{#1}{$\Big/$}\raise0.8ex\hbox{$#2$}}% } {% \textstyle #2\rotatebox{#1}{/}#3 } {% \scriptstyle #2\rotatebox{#1}{/}#3 } {% \scriptscriptstyle #2\rotatebox{#1}{/}#3 } } \newcommand\ABquotient[3][-22]{% #1 is the optional angle, default is 45 \mathchoice {% \displaystyle \text{\lower0.8ex\hbox{$#3$}\rotatebox{#1}{$\Bigg/$}\raise0.8ex\hbox{$#2$}}% } {% \textstyle #2\rotatebox{#1}{/}#3 } {% \scriptstyle #2\rotatebox{#1}{/}#3 } {% \scriptscriptstyle #2\rotatebox{#1}{/}#3 } } \newcommand\ABQuotient[3][-22]{% #1 is the optional angle, default is 45 \mathchoice {% \displaystyle \text{\lower0.8ex\hbox{$#3$}\rotatebox{#1}{\scalebox{1.5}{$\Bigg/$}}\raise0.8ex\hbox{$#2$}}% } {% \textstyle #2\rotatebox{#1}{/}#3 } {% \scriptstyle #2\rotatebox{#1}{/}#3 } {% \scriptscriptstyle #2\rotatebox{#1}{/}#3 } } \newcommand\fquotient[3][22]{% #1 is the optional angle, default is 22 \mathchoice {% \displaystyle \text{\raise1ex\hbox{\hspace{0.4em}$#3$\hspace{-0.4em}}\rotatebox{#1}{$\Big\backslash$}\lower0.8ex\hbox{\hspace{-0.3em}$#2$\hspace{0.3em}}}% } {% \textstyle \hspace{0.8em}#2\rotatebox{#1}{/}\hspace{-0.8em}#3 } {% \scriptstyle \hspace{0.8em}#2\rotatebox{#1}{/}\hspace{-0.8em}#3 } {% \scriptscriptstyle \hspace{0.8em}#2\rotatebox{#1}{/}\hspace{-0.8em}#3 } } \makeatother \usepackage{polyglossia} \setdefaultlanguage{hebrew} \setotherlanguage{english} \begin{document} \begin{center} \begin{tikzpicture} \begin{axis}[ hide axis, view={40}{60}, ] \addplot3[ surf, colormap name=viridis, faceted color=violet, fill=none, samples=22, samples y=30, domain=0:2*pi, domain y=0:2*pi, z buffer=sort, ] ({(3+cos(deg(x)))*cos(deg(y))}, {(3+cos(deg(x)))*sin(deg(y))}, {sin(deg(x))}); \end{axis} \end{tikzpicture} \end{center} \end{document}
- Surface plots using Tikzby skm on December 27, 2024 at 11:09 am
I want to show surface approximation plots, in which I have two variables called calculated and approximated. I need to show two 3D surface plots corresponding to these two variables, whose values are stored in .dat file. I want to have plot as shown in this SO answer. I am able to compile and run the code provided in the answer. However, when I try to make some dummy modifications i.e. adding another hard-coded plot, the code is not running. My non-running Code: \documentclass[border=1cm]{standalone} \usepackage{amsmath} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \pgfplotsset{colormap={violet}{rgb255=(25,25,122) rgb255=(238,140,238) color=(white)}} \begin{document} \begin{tikzpicture}[ declare function={ f(\x,\y)=-exp(-(\x^2+\y^2)/1.3; }] \begin{axis}[ view={30}{20}, mesh/interior colormap name=violet, colormap/viridis, hide axis, xmin=-2, xmax=2, ymin=-2, ymax=2, zmin=-2.5, zmax=0, ] \addplot3[ surf, samples=4, % Reduced number of samples for demonstration domain=-2:2, domain y=-2:2, point meta=explicit, ] table { x y z -2 -2 -2 -1 -2 -1.5 0 -2 -1 1 -2 -0.3 2 -2 0.2 -2 -1 -1.5 -1 -1 -0.8 0 -1 -0.3 1 -1 0.2 2 -1 0.7 -2 0 -1 -1 0 0.1 0 0 0.7 1 0 1.2 2 0 1.5 -2 1 0.2 -1 1 0.6 0 1 1 1 1 1.3 2 1 1.5 -2 2 0.8 -1 2 1 0 2 1.3 1 2 1.5 2 2 1.8 }; \end{axis} \end{tikzpicture} \end{document} How to get a figure like below (Plus added plot using hard-coded or file-loaded values)?
- Beamer theme Metropolis changes TikZ drawby rake on August 11, 2022 at 11:04 pm
I am having trouble adding a TikZ graphic to my Beamer presentation which uses the theme Metropolis. Here is an example of the issue: \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage{pgfplots} %\usetheme{metropolis} \pgfplotsset{compat=1.18} \begin{document} \begin{frame} \begin{center} \begin{tikzpicture} \begin{axis}[ view = {135}{20}, xlabel=$x$, ylabel=$y$, zlabel=$z$, xmin=-1, xmax=1, ymin=-1, ymax=1, zmin=0, zmax=1, ] \draw (0, 1, 0) -- (1, 1, 1); \end{axis} \end{tikzpicture} \end{center} \end{frame} \end{document} This code does what I want, but uncommenting the line \usetheme{metropolis} changes the graphic and makes the line shorter. (I don't think it's invisible, just a very small length.) How can I get the desired image while still using the Metropolis theme?
- Plot differential equation trajectories of a 3-systemby Miguel Huaylla on April 3, 2022 at 10:19 pm
I was reading about drawing differential equation trajectories with latex, but I wonder... is there a way to graph this? Consider the system x'=-y+xz^2 y'=x+yz^2 z'=-z(x^2+y^2) The following image I have taken from Perko's book Differential Equations and Dynamical Systems
- TikZ - 3D surface plotby sobat on January 25, 2022 at 4:33 pm
I want to draw something like this: For the moment I just managed to draw a 3D plate and I don't know how to do it with the 3D sinus curves. I managed to draw something like that, but I don't know how to do for have 2 color in the curve and the same shape. It's not that good !! \documentclass {standalone} \usepackage{pgfplots} \pgfplotsset{compat = newest} \begin{document} \begin{tikzpicture} \begin{axis}[hide axis] \addplot3 [ domain=-2:2, domain y = -2:2, samples = 40, samples y = 40, surf, fill=pink, faceted color = teal] {-exp(-(x^2+y^2)/1.3}; \end{axis} \end{tikzpicture} \end{document} Could you help me?!
- How to best produce a nomogram representing an epicyclic geartrainby John W. de Burgh on December 14, 2021 at 11:21 am
I have a rather philosophical question. I need to produce several so-called nomograms, they represent the relations of an epicyclic gear train used in automatic gearboxes or for the power split device in Toyota hybrids. In the figure below, you can see the equation and the diagram. I did the diagram by brute force, but I would like to generate one using variables. I could do that in the code below, but perhaps pgfplots would be better. What do you think? I hope that the comments in the code are clear enough. Inputs are the revolutions for the electric motor, the internal combustion engine (ICE) and the number of teeth z_crown and z_sun. Output is the third vertical axis. P.S: I just corrected an error in the formula, the equation in the picture is different now. I have also introduced parameters. \documentclass[border=3mm,tikz]{standalone} \usetikzlibrary{arrows,calc} \usetikzlibrary{patterns,decorations.pathreplacing} \newcommand\revem{2600/1000} \newcommand\revice{0} \newcommand\zcrown{78/10} \newcommand\zsun{30/10} \newcommand\zdiv{2.6} \def\revgen{\revice+\revice*\zdiv-\revem*\zdiv} \begin{document} \begin{tikzpicture} % x-axis \draw[thick, red] (0,0) -- (12,0); % first y-axis \draw[thick, red,->] (0,0) -- (0,5); \node at (0,5.5) {\Large $\omega_{em}$}; % revolutions electric motor \draw[very thick, blue] (0,0) -- (0,\revem); % second y-axis \draw[thick, red,->] (\zsun,0) -- (\zsun,5); \node at (\zsun,5.5) {\Large $\omega_{ice}$}; % revolutions ICE \draw[very thick, blue] (\zsun,0) -- (\zsun,\revice); % third y-axis \draw[thick, red,->] (\zcrown+\zsun,0) -- (\zcrown+\zsun,5); \node at (\zcrown+\zsun,5.5) {\Large $\omega_{gen}$}; % revolutions generator \draw[very thick, blue] (\zcrown+\zsun,0) -- (\zcrown+\zsun, \revgen); % connecting revolutions with line \draw[very thick, blue] (0,\revem) -- (\zcrown+\zsun,\revgen); \draw [ thick, decoration={ brace, mirror, raise=0.1cm }, decorate ] (0,0) -- (\zsun,0) node [pos=0.5,anchor=north,yshift=-0.55cm] {$z_{sun}$}; \draw [ thick, decoration={ brace, mirror, raise=0.1cm }, decorate ] (\zsun,0) -- (\zcrown+\zsun,0) node [pos=0.5,anchor=north,yshift=-0.55cm] {$z_{crown}$}; \node at (4,-6) {\Large $\omega_{gen}=\omega_{ice}+(\omega_{ice}-\omega_{em})\frac{z_{crown}}{z_{sun}}$}; \node at (4,-7) {\Large $\omega_{gen}=0+(0-2600)\frac{78}{30}=-6760$}; \end{tikzpicture} \end{document}
- How to make multiple pgfplots share legend and Y label, retaining same size and ability to reference each plot?by Lars Kakavandi-Nielsen on August 25, 2021 at 7:01 am
For some time now I have been trying to have two (or more) plots made with pgfplot side by side (figure below shows my goal for three), with the leftmost plot having the ylabel, the centre having the legend above it (or in case of an even number of plots having the legend centred between the two middle once). Finally, I would like for each plot to have a referencable label and caption (besides the xlabel) However, the plot with the ylabel and the one with the legend always gets smaller (due to the added graphics of the label and the legend, I know) and I have not been able to find a solution to the issue. Is there a way to achieve what I want? Below is the normal way I add three plots using subfigure: \documentclass{report} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usepackage{subcaption} \begin{filecontents}{data.csv} X,Y,Z,N 0,1,2,3 1,2,3,4 2,3,4,5 4,4,5,6 \end{filecontents} \begin{document} \begin{figure} \centering \begin{subfigure}[t]{.3\textwidth} \centering \begin{tikzpicture} \begin{axis}[ylabel=DATA TEXT, width=.95\textwidth] \addplot+ table[x=X, y=Y, col sep=comma] {data.csv}; \end{axis} \end{tikzpicture} \caption{\label{fig:y} Shows Y} \end{subfigure}~ \begin{subfigure}[t]{.3\textwidth} \centering \begin{tikzpicture} \begin{axis}[width=.95\textwidth, legend style={at={(0.5,1.5)},anchor=north,legend columns=2}] \addplot+ table[x=X, y=Z, col sep=comma] {data.csv}; \legend{DATA} \end{axis} \end{tikzpicture} \caption{\label{fig:z} Shows Z} \end{subfigure}~ \begin{subfigure}[t]{.3\textwidth} \centering \begin{tikzpicture} \begin{axis}[width=.95\textwidth] \addplot+ table[x=X, y=N, col sep=comma] {data.csv}; \end{axis} \end{tikzpicture} \caption{\label{fig:n} Shows N} \end{subfigure} \end{figure} \end{document}
- Shift scatter plot according to classby fuj36840 on July 22, 2020 at 5:20 pm
I have a scatter plot with many points at the same coordinate. I would like to shift every point belonging to one class a bit on the x-axis, so that they are more easily distinguishable. I've tried to adapt this question, but could not figure it out. MWE: \documentclass{scrbook} \usepackage{siunitx} \usepackage{xcolor} \definecolor{mgelb}{RGB}{255, 187, 0} \definecolor{mblau}{RGB}{10, 59, 104} \definecolor{mturkis}{RGB}{0, 171, 183} \definecolor{mrot}{RGB}{255, 70, 70} \definecolor{mrot2}{RGB}{184, 0, 0} \definecolor{mgrun}{RGB}{41, 175, 0} \definecolor{mlila}{RGB}{136, 55, 155} \definecolor{mgrau1}{RGB}{230, 230, 230} \definecolor{mgrau2}{RGB}{204, 204, 204} \definecolor{mgrau3}{RGB}{153, 153, 153} \usepackage{pgfplots}\pgfplotsset{compat=1.16} \usepackage{pgfplotstable} \usepgfplotslibrary{groupplots} \pgfplotsset{ table/search path={../Versuche}, jitter/.style={x filter/.code={\pgfmathparse{\pgfmathresult+rand*#1}}}, jitter/.default=0 } \pgfplotsset{legend cell align={left}, legend style={/tikz/every even column/.append style={column sep=0.3cm}}} \begin{document} \pgfkeys{/pgf/number format/read comma as period} \pgfplotstableread{ Quadrant Bereich Nummer Rz_m Rz_s 0 0 1 67,90 0,64 0 0 2 44,17 0,77 0 0 3 44,30 2,73 0 0 4 63,43 1,39 0 0 5 49,87 1,74 0 0 6 39,33 1,15 I a 1 61,17 0,31 I a 2 69,37 0,73 I a 3 66,20 1,5 I a 4 44,20 0,08 I a 5 64,77 2,65 I a 6 39,93 0,09 I i 1 44,33 0,05 I i 2 50,97 3,94 I i 3 55,90 2,41 I i 4 51,33 0,52 I i 5 58,23 2,31 I i 6 44,53 1,23 II a 1 50,03 0,05 II a 2 47,40 0,14 II a 3 58,67 3,63 II a 4 71,57 1,68 II a 5 57,60 0,08 II a 6 70,77 0,26 II i 1 63,93 0,05 II i 2 47,37 0,12 II i 3 46,90 0,62 II i 4 34,73 2,6 II i 5 41,27 0,45 II i 6 48,23 0,12 III a 1 58,30 0,4 III a 2 47,07 0,05 III a 3 50,53 0,69 III a 4 51,20 0,14 III a 5 32,67 0,12 III a 6 50,37 0,39 III i 1 37,50 0,14 III i 2 55,50 0,42 III i 3 41,20 0,16 III i 4 48,07 0,45 III i 5 56,80 1,2 III i 6 49,77 0,68 IV a 1 40,87 0,68 IV a 2 44,43 1,37 IV a 3 44,00 0,36 IV a 4 60,03 0,12 IV a 5 63,73 0,09 IV a 6 72,80 0,08 IV i 1 51,60 0,14 IV i 2 45,53 0,05 IV i 3 60,27 0,95 IV i 4 71,00 3,12 IV i 5 59,63 0,05 IV i 6 48,70 1,16 }\data \begin{figure} \centering\small \begin{tikzpicture} \begin{groupplot}[ group style={group size=2 by 1, ylabels at=edge left, horizontal sep=2cm}, xtick=data, ymin=0, ylabel=$R_{z}$ in \si{\um}, legend pos=south west, legend columns=-1, width=0.5\textwidth, height=0.6\textwidth, clip mode=individual, ] \nextgroupplot[ symbolic x coords={0, i, a}, xlabel={Bereich}, scatter/classes={0={mgrun}, I={mblau, xshift=-1mm}, II={mgelb, xshift=1mm}, III={mturkis, xshift=-3mm}, IV={mrot2, xshift=3mm}} ] \addplot[ scatter, only marks, error bars/.cd, y dir=both, y explicit] table[meta=Quadrant, scatter src=explicit symbolic, x=Bereich, y=Rz_m, y error=Rz_s] {\data}; \legend{0, I, II, III, IV} \nextgroupplot[ symbolic x coords={0, i, a}, xlabel={Bereich}, xtick={0, i, a}, scatter/classes={0={mgrun}, I={mblau}, II={mgelb}, III={mturkis}, IV={mrot2}} ] \addplot[ jitter=0.1, scatter, only marks, error bars/.cd, y dir=both, y explicit] table[meta=Quadrant, scatter src=explicit symbolic, x=Bereich, y=Rz_m, y error=Rz_s] {\data}; \legend{0, I, II, III, IV} \end{groupplot} \end{tikzpicture} \end{figure} \end{document} EDIT: There are two methods for shifting the points and both are flawed: using xshift=-1mm in each scatter/class (left). The error bars stay at the same location. using jitter/.style (right). This also shifts the error bars, but at random locations, also resulting in overlaps.
- How can I do a barrelby Angelo Aliano Filho on March 19, 2020 at 6:14 pm
Hello dear users of PGFplots, I need to do this figure, a barrel. How can I do this by using PGFplots?
- How to make the axes physically properly clip through a sphere?by Jack Tiger Lam on September 28, 2019 at 7:46 am
I have only seen questions where people wanted the axis to be overlaid on top of the plot. I want to do something more advanced. I want the axes to be rendered behind where you would expect them to be inside the surface, and rendered in front where you would expect them to be outside the surface. The first image is what I currently have. The second image is approximately what I would like to have. (apologies for the poor paint edit) \documentclass{article} \usepackage[a4paper,top=3cm,bottom=3cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry} \usepackage{amsmath} \usepackage{amssymb} \usepackage{tikz} \usepackage{pgfplots} \usepgfplotslibrary{patchplots} \usepgfplotslibrary{colormaps} \pgfplotsset{compat=1.8} \usetikzlibrary{arrows.meta} \usetikzlibrary{shadings} \usepackage{xcolor} \begin{document} \begin{tikzpicture}[scale=2] \begin{axis}[axis equal image, axis lines=center, ticks=none, view/h=120, view/v=20, enlarge x limits={abs=27pt}, enlarge y limits={abs=13.3pt}, enlarge z limits={abs=10pt}] %sphere \addplot3[surf, shader=interp ,colormap={custom}{rgb255=(200,200,200)rgb255=(200,200,200)}, opacity=0.5, z buffer = sort, samples = 50, variable = \u, variable y = \v, domain = 0:180, y domain = 0:360] ({2*cos(u)*sin(v)}, {2*sin(u)*sin(v)}, {2*cos(v)}); %viviani cylinder parts \addplot3[surf, shader=interp, colormap={grayslate}{rgb255=(50,50,50)rgb255=(200,200,200)}, opacity=0.5, z buffer = sort, samples = 35, variable = \u, variable y = \v, domain = 0:360, y domain = -2:0, ] ({1+cos(u)}, {sin(u)}, {max(-sqrt(2*(2-x)),v)}); \addplot3[surf, shader=interp, colormap={grayslate}{rgb255=(50,50,50)rgb255=(200,200,200)}, opacity=0.5, z buffer = sort, samples = 35, variable = \u, variable y = \v, domain = 0:360, y domain = 0:2, ] ({1+cos(u)}, {sin(u)}, {min(sqrt(2*(2-x)),v)}); %viviani window edge \addplot3+[domain=0:4*pi, samples=50, samples y=0, no marks, smooth, thick, black]({1+cos(deg(x))},{sin(deg(x))},{2*sin(deg(x)/2)}); %equator \addplot3+[domain=0:2*pi, samples=50, samples y=0, no marks, smooth, dotted, black, line width=0.5pt]({2*cos(deg(x))},{2*sin(deg(x))},{0}); %equator cylinder \addplot3+[domain=0:2*pi, samples=30, samples y=0, no marks, smooth, solid, thick, black]({1-cos(deg(x))},{sin(deg(x))},{0}); \end{axis} \end{tikzpicture} \end{document}
- PGFplots - Imitate minimalistic styleby pogo-otter on April 8, 2019 at 5:38 pm
The style of plots, as shown in the example of a thesis I saw, can be found in literature of topics ranging from mechanical engineering to physics. I am primarily interested to know if this is a specific style option or package (like using colorbrewer sets for colours). (If it is none of this, I will try to re-imagine it myself.) So far, I have checked the TikZ Galery for any other examples of this and looked through math sans serif fonts, but it was not successful yet. Just as an addition, the reason I am searching for a package or something similar, is that this style of diagram is fairly widespread. And not only do the axes look differently than regular pgfplots (see the dimensions for the percentage on the y-axis), there's also the different fontand the arrows in the axis description. These characteristics are always the same when these diagrams can be found in books which makes me think that this is a fundamental design.
- pgfplots: How to imitate MATLAB filled contour plot?by Diaa on January 22, 2017 at 11:04 am
Following this answer, I have a data file P.dat which I need to plot it as a filled contour plot. However, I got this error: Package pgfplots Error: CRITICAL: shader=interp: got unsupported pdf shading type '0'. This may corrupt your pdf!. \end{axis} I would be grateful if I could know the error source and how I can make the output match the MATLAB desired one. P.dat http://pastebin.com/PAvQMxdC MWE \RequirePackage{luatex85} \documentclass[tikz]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis} \addplot3[contour filled] table {P.dat}; \end{axis} \end{tikzpicture} \end{document} MATLAB Desired Output Update 1 I made another data file with NaN z values to account for the void data (white space) and specified the number of rows and columns, but I got this undesired output. P2.dat http://pastebin.com/CCUjeQUm MWE 2 \RequirePackage{luatex85} \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{patchplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[view={0}{90}] \addplot3[contour filled,mesh/rows=31,mesh/cols=11,mesh/check=false] table {P2.dat}; \end{axis} \end{tikzpicture} \end{document} Output 2## Update 2 Recalling my raw MATLAB data, how can I remove all the points whose z values equal to or exceed 1723 in order to get an output similar to my desired one? P3.dat http://pastebin.com/jvNVfJMU MWE 3 \RequirePackage{luatex85} \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{patchplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[view={0}{90},colorbar, point meta max=1723, point meta min=300,] \addplot3[contour filled={number = 25,labels={false}},mesh/rows=31,mesh/cols=11,mesh/check=false ] table {P3.dat}; \end{axis} \end{tikzpicture} \end{document} Output 3
- 3D spherical coordinate system in pgf plotsby Tony Mau on June 27, 2016 at 5:01 am
I just learned 3d rectangular graphs in pgf-plots, and now I need to graph in spherical coordinates. Ive been reading the manual and cant find an answer. Is there a simple way to plot something such as rho=1+sin(theta)*sin(phi). Thank you for the help. \begin{tikzpicture} \begin{axis}[ xmin=-5,xmax=5, ymin=-5,ymax=5, zmin=-5,zmax=5, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}, zlabel style={rotate=90}, view={75}{20}] addplot3[surf,opacity=0.75,domain=-360:360,y domain=-360:360,samples=20]({x},{y},{1+0.2*sin(x)*sin(y)}); \end{axis} \end{tikzpicture}
- Automatically externalizing content of a PGFplot as a PNGby David Z on March 9, 2016 at 5:44 am
I've got basically the same issue as in this question: I have a rather complicated plot made with PGFplots and I can get a very significant file size reduction by using a rasterized image (PNG) instead of a PDF. The main solution suggested in that question's answer is to convert the externalized PDF into high resolution PNG files and include those back in the document, presumably using \includegraphics or the equivalent. OK, fine, I can do that. But let's say I'd like to keep the axes and descriptions in vector "format", and only have the content of the plot as a PNG. A lot of the technology to do this automatically already exists: PGFplots can create the content of an axis without the lines and labels (though still including titles and legends) using the hide axis style It can export single-plot images using the external library It can automatically rasterize externalized images using e.g. convert, as requested in this question It can use an external raster image as the content of a plot, using the \addplot graphics mechanism So could we stitch together all these steps to make a PGFplots style that automatically writes out the content of a plot as a PNG file and then displays it inside axes? (My use case involves 2D plots only, though if someone wanted to take on the challenge of doing this for 3D plots I wouldn't complain!) The main obstacle, for me at least, is externalizing a plot that is not directly displayed in the document, and doesn't actually exist as its own separate tikzpicture. Taking a sample plot: \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \addplot {x + 1}; \end{axis} \end{tikzpicture} \end{document} my thought would be to (somehow) convert the tikzpicture environment to \begin{tikzpicture}[undisplayed,tikz/external/figure name=randomname] \begin{axis}[hide axis] \addplot {x + 1}; \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis} \addplot graphics {randomname}; \end{axis} \end{tikzpicture} and only display the second picture (hence the hypothetical undisplayed style, though I don't know if such a thing is really possible). Of course I'm not sure how to do this. Perhaps someone more familiar with the PGFplots/TikZ internals would know a way, if it's possible? Or perhaps there's some other way to get to the same end, maybe by choosing what styles to apply to the picture depending on what step in the process we're in.
- Can pgfplots display the intersection of two surfaces?by Brian Fitzpatrick on February 29, 2016 at 7:08 am
I'm trying to depict Viviani's curve with tikz. Ideally my picture would look like this one: (source) My code is \documentclass[]{standalone} \usepackage{pgfplots} \usepackage{tikz} \begin{document} \begin{tikzpicture} \begin{axis}[axis lines=center, ticks=none, view/h=120, view/v=5] \addplot3+[domain=0:4*pi, samples=100, samples y=0, no marks, smooth, ultra thick,black]( {1+cos(deg(x))}, {sin(deg(x))}, {2*sin(deg(x)/2)} );% node[blue,circle,fill,pos=0.3]{} node[red,draw,pos=0.65,thick]{}; \addplot3[% opacity = 0.1, mesh, blue, z buffer = sort, samples = 50, variable = \u, variable y = \v, domain = 0:180, y domain = 0:360, ] ({2*cos(u)*sin(v)}, {2*sin(u)*sin(v)}, {2*cos(v)}); \addplot3[% opacity = .1, mesh, red, z buffer = sort, samples = 50, variable = \u, variable y = \v, domain = 0:360, y domain = -2:2, ] ({1+cos(u)}, {sin(u)}, {v}); \end{axis} \end{tikzpicture} \end{document} This produces The plot doesn't convey the intersection very well. Is my code salvageable?
- Drawing intersection of plane and parabolic surface in PGFplotsby walkar on September 5, 2015 at 7:20 pm
I want to draw the surface x^2-y in PGFplots in 3D and intersect it with the plane z=1, emphasizing the intersection probably with some coloration or shading or something. I'd also like to emphasize the y-axis and the z-axis. I've read a few similar posts on here and tried to edit them, but I can't seem to get them into the shape I want. Does anyone have a suggestion for something I can try? EDIT: I've been working up a minimum working example of the code, where the intersection is not at all emphasized. Also, I've read elsewhere now that there are problems drawing intersections with PGFplots and that sometimes PStricks is better. I'm fine with either solution, I just want something that works. \documentclass[12pt]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} [ xlabel = $x_1$, ylabel = $x_2$, zlabel = $x_3$, zlabel style={rotate = -90}, zmin = 0, zmax = 2 ] \addplot3[surf,mesh,shader=faceted,samples=20] (x,y,1); \addplot3[surf,shader=interp,samples=50] {x*x - y}; \end{axis} \end{tikzpicture} \end{document} The result looks like crap in my opinion, but I have no idea how to make it look nice.
- 3d Graph Error with Plotby dreez91 on June 16, 2015 at 3:25 pm
I have a problem with plotting a 3d-graph \documentclass[border=5pt]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ title=Exmple using the mesh parameter, hide axis, colormap/cool, ] \addplot3[ mesh, samples = 40, domain=0:1, ] {exp(-(ln(x)-ln(y)))}; \addlegendentry{$\frac{sin(r)}{r}$} \end{axis} \end{tikzpicture} \end{document} The problem is NOTE: coordinate (0Y0.0e0],0Y0.0e0],3Y0.0e0]) has been dropped because it is un bounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y2.5641e-2],0Y0.0e0],3Y0.0e0]) has been dropped because it i s unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y5.1282e-2],0Y0.0e0],3Y0.0e0]) has been dropped because it i s unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y7.6923001e-2],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y1.02564001e-1],0Y0.0e0],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y1.2820499e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y1.5384598e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y1.7948697e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y2.0512796e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y2.3076895e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y2.5640994e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y2.8205093e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y3.0769193e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y3.3333292e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y3.589739e-1],0Y0.0e0],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y3.846149e-1],0Y0.0e0],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y4.1025589e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y4.3589688e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y4.6153787e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y4.8717886e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y5.1281985e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y5.3846085e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y5.6410184e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y5.8974283e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y6.1538382e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y6.4102481e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y6.666658e-1],0Y0.0e0],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y6.923068e-1],0Y0.0e0],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y7.1794778e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y7.4358878e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y7.6922977e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y7.9487076e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y8.2051175e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y8.4615274e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y8.7179373e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y8.9743472e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y9.2307571e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y9.487167e-1],0Y0.0e0],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y9.743577e-1],0Y0.0e0],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (1Y9.9999869e-1],0Y0.0e0],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y2.5641e-2],3Y0.0e0]) has been dropped because it i s unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y5.1282e-2],3Y0.0e0]) has been dropped because it i s unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y7.6923001e-2],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y1.02564001e-1],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y1.2820499e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y1.5384598e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y1.7948697e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y2.0512796e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y2.3076895e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y2.5640994e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y2.8205093e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y3.0769193e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y3.3333292e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y3.589739e-1],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y3.846149e-1],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y4.1025589e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y4.3589688e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y4.6153787e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y4.8717886e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y5.1281985e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y5.3846085e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y5.6410184e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y5.8974283e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y6.1538382e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y6.4102481e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y6.666658e-1],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y6.923068e-1],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y7.1794778e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y7.4358878e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y7.6922977e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y7.9487076e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y8.2051175e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y8.4615274e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y8.7179373e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y8.9743472e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y9.2307571e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y9.487167e-1],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y9.743577e-1],3Y0.0e0]) has been dropped because it is unbounded (in z). (see also unbounded coords=jump). NOTE: coordinate (0Y0.0e0],1Y9.9999869e-1],3Y0.0e0]) has been dropped because i t is unbounded (in z). (see also unbounded coords=jump). ! Package pgfplots Error: An internal error occurred during z buffer reordering s: the rows/cols where not balanced! I have rows= 40, cols=40. If this happens to be wrong, you might want to provide rows and cols manually.. See the pgfplots package documentation for explanation. Type H <return> for immediate help. ... l.17 \end{axis} ? Is there anyone who knows how to fix the problem? It works e.g. with the function sin(x)*sin(y)...
- Draw closed section of sphere using pgfplotsby Zac on November 15, 2014 at 2:50 pm
I want to draw a section of a sphere to represent its volume. I have currently got the following: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} \begin{axis}[ axis equal, axis lines = center, width = 10cm, height = 10cm, xlabel = {$x$}, ylabel = {$y$}, zlabel = {$z$}, view/h=45, ] \addplot3[surf, opacity = 0.5, samples=21, domain=0:1, y domain=0:0.5*pi, z buffer=sort] ({sqrt(1-x^2) * cos(deg(y))}, {sqrt( 1-x^2 ) * sin(deg(y))}, x); \end{axis} \end{tikzpicture} \end{document} Which gives me: But I want the sides to be closed, something like this: How can I do this?
- Drawing a Cube with Tikz/PgfPlots Looks Stretched along X-Axisby Rüdiger on October 10, 2014 at 10:38 am
I'm trying to draw a cubic structure (fcc crystal structure) with Tikz. I'm using pgfplots's axis cs function for the 3D projection. But the result looks like a rectangle stretched along the x axis. Here is the result: Here is the code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc,arrows,positioning} \usepackage{pgfplots} \pgfplotsset{compat=1.9} \begin{document} \begin{tikzpicture}[ vector/.style={thick,black,>=stealth,->}, atom/.style={blue} ] \begin{axis}[ axis lines=none, xmin=-0.1, xmax=1.1, ymin=-0.1, ymax=1.1, zmin=-0.1, zmax=1.1, xtick=\empty, ytick=\empty, ztick=\empty ] \coordinate (A0) at (axis cs:0,0,0); \coordinate (A1) at (axis cs:1,0,0); \coordinate (A2) at (axis cs:0,1,0); \coordinate (A3) at (axis cs:0,0,1); \coordinate (A4) at (axis cs:1,1,0); \coordinate (A5) at (axis cs:1,0,1); \coordinate (A6) at (axis cs:0,1,1); \coordinate (A7) at (axis cs:1,1,1); \coordinate (A8) at (axis cs:0.5,0.5,0); \coordinate (A9) at (axis cs:0.5,0,0.5); \coordinate (A10) at (axis cs:0,0.5,0.5); \coordinate (A11) at (axis cs:0.5,0.5,1); \coordinate (A12) at (axis cs:0.5,1,0.5); \coordinate (A13) at (axis cs:1,0.5,0.5); \draw[black!25] (A0) -- (A8) -- (A4); \draw[black!25] (A4) -- (A12) -- (A6); \draw[black!25] (A0) -- (A10) -- (A6); \draw[black!25] (A1) -- (A8) -- (A2); \draw[black!25] (A2) -- (A10) -- (A3); \draw[black!25] (A7) -- (A12) -- (A2); \draw[black] (A1) -- (A13) -- (A7); \draw[black] (A3) -- (A11) -- (A7); \draw[black] (A5) -- (A13) -- (A4); \draw[black] (A6) -- (A11) -- (A5); \draw[black] (A5) -- (A9) -- (A0); \draw[black] (A0) -- (A1); \draw[black] (A0) -- (A2); \draw[black] (A0) -- (A3); \draw[black] (A0) -- (A3); \draw[black] (A3) -- (A5); \draw[black] (A3) -- (A6); \draw[black] (A6) -- (A2); \draw[black] (A5) -- (A1); \draw[black] (A7) -- (A4); \draw[black] (A5) -- (A7); \draw[black] (A1) -- (A4); \draw[black] (A6) -- (A7); \draw[black] (A2) -- (A4); \fill[blue] (A8) circle (5pt); \draw[vector] (A0) -- (A8); \fill[blue] (A10) circle (5pt); \draw[vector] (A0) -- (A10); \draw[black] (A3) -- (A9) -- (A1); \fill[atom] (A1) circle (5pt); \fill[atom] (A2) circle (5pt); \fill[atom] (A3) circle (5pt); \fill[atom] (A4) circle (5pt); \fill[atom] (A5) circle (5pt); \fill[atom] (A6) circle (5pt); \fill[atom] (A7) circle (5pt); \fill[atom] (A9) circle (5pt); \fill[atom] (A11) circle (5pt); \fill[atom] (A12) circle (5pt); \fill[atom] (A13) circle (5pt); \draw[vector] (A0) -- (A9); \fill[blue] (A0) circle (5pt); \end{axis} \end{tikzpicture} \end{document} What causes the stretching? How can I change it into a perfect cube?
- Flip x and y axis of ternary graphby Raphael on July 18, 2014 at 4:27 am
I am trying to reproduce the USDA Soil Triangle. To do so, I would need to flip the x and y axis of the default pgfplots-ternary. I understand, that I could switch my inputs (don't really want to do that), but I would need to change the directions as well, and I not even having any success with that. In the default ternary axis, the y axis is on the left and the x axis is on the right, and x runs from 0 (bottom right) to 100 (top) and y runs from top to bottom left. However, according to the USDA Soil Triangle, x needs to run from bottom left to top, y needs to run from top to bottom right, and z from bottom right to bottom left. Also, the x axis (and ticks) need to be horizontal (parallel to z), whereas y needs to be parallel to x and z should be parallel to y. I tried the x dir=reverse and axis on top commands, as I thought I could simply flip my coordinates, but I had no luck. Did anybody ever have a similar problem or knows an answer to this? I did what I could to at least have all the data and such. Here is what I got: \documentclass[]{standalone} \usepackage[dvipsnames]{xcolor} % color handling \usepackage{tikz} % draw pictures and diagrams \usepackage{pgfplots} % proper plotting \usepackage{file contents} % writing reading of data files \usepgfplotslibrary{ternary, units} \begin{filecontents*}{USDASoils.csv} name,clay,silt,sand Sand,0,0,100 Sand,10,0,90 Sand,0,15,85 Loamy Sand,0,15,85 Loamy Sand,10,0,90 Loamy Sand,15,0,85 Loamy Sand,0,30,70 Clay,55,0,45 Clay,100,0,0 Clay,60,40,0 Clay,40,40,20 Clay,40,15,45 Sandy Clay,35,0,65 Sandy Clay,55,0,45 Sandy Clay,35,20,45 Silty Clay,40,40,20 Silty Clay,60,40,0 Silty Clay,40,60,0 Loam,8,40,52 Loam,20,27,53 Loam,27,28,45 Loam,27,50,23 Loam,8,50,42 Sandy Loam,0,30,70 Sandy Loam,15,0,85 Sandy Loam,20,0,80 Sandy Loam,20,27,53 Sandy Loam,8,40,52 Sandy Loam,8,50,42 Sandy Loam,0,50,50 Clay Loam,27,28,45 Clay Loam,40,15,45 Clay Loam,40,40,20 Clay Loam,27,53,20 Sandy Clay Loam,20,0,80 Sandy Clay Loam,35,0,65 Sandy Clay Loam,35,20,45 Sandy Clay Loam,27,28,45 Sandy Clay Loam,20,27,53 Silty Loam,0,50,50 Silty Loam,27,50,23 Silty Loam,27,73,0 Silty Loam,13,87,0 Silty Loam,13,80,7 Silty Loam,0,80,20 Silty Clay Loam,27,53,20 Silty Clay Loam,40,40,20 Silty Clay Loam,40,60,0 Silty Clay Loam,27,73,0 Silt,0,80,20 Silt,13,80,7 Silt,13,87,0 Silt,0,100,0 \end{filecontents*} \pgfplotsset{ discard if not/.style 2 args={ x filter/.code={ \edef\tempa{\thisrow{#1}} \edef\tempb{#2} \ifx\tempa\tempb \else \def\pgfmathresult{inf} \fi } } } \begin{document} \begin{tikzpicture}[scale=0.9] \begin{ternaryaxis}[ xmax=100, ymax=100, zmax=100, ternary limits relative, xlabel=x (Clay), ylabel=y (Silt), zlabel=z (Sand), xtick={0,10,...,100}, ytick={0,10,...,100}, ztick={0,10,...,100}, minor tick num=1, grid=both, ] \def\myopacity{0.5} % Sands \addplot3 [fill=yellow, fill opacity=\myopacity, discard if not={name}{Sand}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; \addplot3 [fill=Melon, fill opacity=\myopacity,discard if not={name}{Loamy Sand}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; % Sand Text \node at (axis cs:3,5,) {\tiny Sand}; \node at (axis cs:5,13) {\tiny Loamy}; \node at (axis cs:2,18) {\tiny Sand}; % Clays \addplot3 [fill=yellow, fill opacity=\myopacity, discard if not={name}{Clay}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; \addplot3 [fill=red, fill opacity=\myopacity, discard if not={name}{Sandy Clay}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; \addplot3 [fill=Aquamarine!50, fill opacity=\myopacity, discard if not={name}{Silty Clay}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; %Clay Text \node at (axis cs:65,16) {\tiny Clay}; \node at (axis cs:43,6) {\tiny Sandy}; \node at (axis cs:38,8) {\tiny Clay}; \node at (axis cs:48,47) {\tiny Silty}; \node at (axis cs:44,49) {\tiny Clay}; % Loams \addplot3 [fill=brown, fill opacity=\myopacity, discard if not={name}{Loam}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; \addplot3 [fill=purple!50, fill opacity=\myopacity, discard if not={name}{Sandy Loam}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; \addplot3 [fill=purple!25, fill opacity=\myopacity, discard if not={name}{Sandy Clay Loam}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; \addplot3 [fill=SpringGreen, fill opacity=\myopacity, discard if not={name}{Clay Loam}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; \addplot3 [fill=Green, fill opacity=\myopacity, discard if not={name}{Silty Loam}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; \addplot3 [fill=Aquamarine, fill opacity=\myopacity, discard if not={name}{Silty Clay Loam}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; % Loams Text \node at (axis cs:19,40) {\tiny Loam}; \node at (axis cs:12,23) {\tiny Sandy Loam}; \node at (axis cs:28,13) {\tiny Sandy Clay Loam}; \node at (axis cs:33,35) {\tiny Clay Loam}; \node at (axis cs:13,65) {\tiny Silty Loam}; \node at (axis cs:36,55) {\tiny Silty}; \node at (axis cs:31,58) {\tiny Clay Loam}; % Silts \addplot3 [fill=green, fill opacity=\myopacity, discard if not={name}{Silt}] table [x=clay,y=silt,z=sand, col sep=comma] {USDASoils.csv}; % Silt Text \node at (axis cs:6,88) {\tiny Silt}; \end{ternaryaxis} \end{tikzpicture} \end{document} Which looks like this: I am considerably happy with my result, but I would like to: Switch the axis (as explained above), Remove the minor ticks (but keep the minor grid - I could not get that to work), and have the axis labels sloped along the triangle sides (as in the original picture above)
- Intersecting planes not shown correctly with TikZby George Urvey on April 17, 2013 at 10:14 am
I made a plot in MATLAB of a deformed and an undeformed model. I converted the figure to TikZ using matlab2tikz and added it to my .tex file. I then noticed that the two configurations, which are intersecting, are not displayed correctly. To illustrate what I mean, I've stripped down the TikZ code to make to rectangles cross in a 3D space: \begin{tikzpicture} \begin{axis}[% width=5cm,height=5cm, view={-37.5}{45}, scale only axis, xmin=-3, xmax=23, ymin=0, ymax=20, zmin=-5, zmax=5, hide axis] \addplot3 [fill=white!80!red,opacity=0.5,draw=black] table[row sep=crcr]{ 20 0 0\\ 20 20 0\\ 0 20 0\\ 0 0 0\\ }; \addplot3 [fill=white!80!blue,opacity=0.8,draw=black] table[row sep=crcr]{ 15 5 -4\\ 15 15 0\\ 5 15 4\\ 5 5 0\\ }; \end{axis} \end{tikzpicture} The result looks like this: As can be seen one plane lies entirely on top of the other, while in fact they intersect (i.e. about half of the blue plane lies 'underneath' the red plane). With my minimum TikZ knowledge I was hoping someone here could help me fix this problem, such that the planes indeed intersect.
- Intersection of 2 surface plots in pgfplotsby meep.meep on September 24, 2012 at 6:42 pm
My question is pretty much a duplicate of this one. I'd like pgfplots to display the intersection between tho surface plots properly. Unfortunately, my function is quite different from the one in the mentioned question, so I don't know, where the surfaces will meet. Would there be any kind of workaround for this kind of function? \documentclass{scrartcl} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[domain=0.01:30] \addplot3[surf] {0}; \addplot3[surf] {(1-0.3)*e^(-x*(y/100)*(1-0.3))-e^(-x*(y/100))}; \end{axis} \end{tikzpicture} \end{document}
- Pgfplots: plot graph inside tableby Frank Zafka on May 29, 2011 at 12:41 pm
I would like to plot a table with a graph inside it. I am trying to use this example as a guide. This is the current hand-constructed version. UPDATE: I don't have enough reputation to answer my own question, but I'm getting there: I have got this far, using \multirow So with a little tweaking I may be able to get it to work? I will come back and edit if I do. \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{tikz} \usepackage{dcolumn} \usepackage{multirow} \usepackage{booktabs} \usepackage{lscape} \usepackage{verbatim} \usepackage{pgfplots} \begin{document} \newcommand{\errplot}{% \begin{tikzpicture} \begin{axis}%[xmin=-1.5,xmax=1.5, ymin=-.5,ymax=23,grid=both] \addplot+[only marks][error bars/.cd,x dir=both, x explicit] coordinates { (-0.42,22)+-(0.86,-1.7) (0.04,21)+-(0.9,-0.81) (0.1,20)+-(0.69,-0.49) (0.3,19)+-(0.7,-0.1) (0.8,18)+-(0.72,0.88) (0.37,17)+-(0.7,0.04) (-0.03,16)+-(0.68,-0.75) (-0.3,15)+-(0.53,-1.13) (0.32,14)+-(0.54,0.1) (-0.38,13)+-(0.55,-1.31) (0.12,12)+-(0.54,-0.3) (-0.1,11)+-(0.53,-0.73) (0.12,10)+-(0.55,-0.32) (-0.2,9)+-(0.57,-0.97) (-0.39,8)+-(0.58,-1.36) (-0.35,7)+-(0.57,-1.27) (0.09,6)+-(0.56,-0.37) (-0.53,5)+-(0.55,-1.62) (0.23,4)+-(0.56,-0.11) (0.18,3)+-(0.58,-0.21) (0.05,2)+-(0.57,-0.47) (0.02,1)+-(0.55,-0.52) }; \addplot[dashed] coordinates {(0,-1) (0,24)}; \end{axis} \end{tikzpicture}% } \begin{table}[h!] \centering \begin{tabular}{c c c c c} \hline & & & & Standardised \\ & & z & \emph{p} & Mean (95\% CI) \\ [0.5ex] \hline Afear & \multirow{22}{8cm}{\errplot} & -0.96 & 0.33 & -0.42 (-1.28 to 0.44) \\ Anofear & & 0.09 & 0.93 & 0.04 (-0.85 to 0.94) \\ B+2 & & 0.29 & 0.78 & 0.10 (-0.59 to 0.79) \\ B+1 & & 0.84 & 0.40 & 0.30 (-0.40 to 1.00) \\ B1:1 & & 2.19 & 0.03 & 0.80 (0.08 to 1.52) \\ B-1 & & 1.02 & 0.31 & 0.37 (-0.33 to 1.07) \\ B-2 & & -0.10 & 0.92 & -0.03 (-0.72 to 0.65) \\ C+2 & & -1.11 & 0.27 & -0.30 (-0.83 to 0.23) \\ C+1 & & 1.15 & 0.25 & 0.32 (-0.22 to 0.86) \\ C1:1 & & -1.34 & 0.18 & -0.38 (-0.93 to 0.17) \\ C-1 & & 0.43 & 0.67 & 0.12 (-0.42 to 0.66) \\ C-2 & & -0.37 & 0.71 & -0.10 (-0.63 to 0.43) \\ D+2 & & 0.41 & 0.68 & 0.12 (-0.44 to 0.67) \\ D+1 & & -0.69 & 0.49 & -0.20 (-0.77 to 0.37) \\ D1:1 & & -1.33 & 0.18 & -0.39 (-0.97 to 0.19) \\ D-1 & & -1.21 & 0.23 & -0.35 (-0.92 to 0.22) \\ D-2 & & 0.32 & 0.75 & 0.09 (-0.46 to 0.65) \\ E+2 & & -1.89 & 0.06 & -0.53 (-1.09 to 0.02) \\ E+1 & & 0.78 & 0.44 & 0.23 (-0.34 to 0.79) \\ E1:1 & & 0.62 & 0.53 & 0.18 (-0.39 to 0.76) \\ E-1 & & 0.17 & 0.86 & 0.05 (-0.52 to 0.62) \\ E-2 & & 0.06 & 0.95 & 0.02 (-0.54 to 0.57) \\ [1ex] \hline \end{tabular} \end{table} %\end{landscape} \end{document}