Hot answers tagged

16

You can change the automatic tick distance with the key xtick distance which is available in PGFPlots v1.13. See section 4.15.1 on page 311 of the manual. \documentclass{standalone} \usepackage{amsmath,tikz,pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ xtick distance={60}, ] \addplot coordinates { (0,0) (...


13

You could use intersection segments: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.15}% <- added!! \usepgfplotslibrary{fillbetween}% <- changed \begin{document} \begin{tikzpicture} \begin{axis}[grid = both, set layers% <- added ] % Outer curve \addplot [data cs=polar, domain=0:360, samples=180, black, line ...


11

Here we go, using the y coord trafo key from pgfplots. The symlog function is defined using the tikzmath. It is the function For some reason, I can't seem to be able to plot a tikzmath function including if conditionals with pgfplots, hence the clumsiness of the symlog internals. We also define the inverse transform symexp and feed it to the y coord inv ...


10

You can use xtick={0,...,8}, ytick={0,...,6}, to suppress the ticks and then extra x ticks={9}, extra y ticks={7}, extra tick style={tick style={draw=none}}, to add the grid lines back without ticks; of course, now there's no need for xticklabels nor yticklabels. The complete code: \documentclass[border=5pt,tikz]{standalone} \usepackage[utf8]{...


9

x axis line style={shorten <=-0.5\pgflinewidth} is one option, and while you do say you don't want to tinker with half line widths, at least that one gets the width of the path, so if you add e.g. thick to the axis options, it still works. Another option is x axis line style={line cap=rect}, see section 15.3.1 Graphic Parameters: Line Width, Line Cap, ...


9

\documentclass[border=3pt,tikz]{standalone} \usetikzlibrary{decorations.pathreplacing} \begin{document} \begin{tikzpicture} \draw[very thick,-{latex}] (0,0) -- (6,0) node[below]{$x$}; \foreach \x/\l in {1/-r,3/{},5/+r} \draw (\x,3pt) -- (\x,-3pt) node[below]{$x_0\l$}; \draw [decorate,decoration={brace,amplitude=5pt,mirror,raise=4ex}] (1,0) -- (5,0) ...


8

This is where the x coord trafo and x coord inv trafo mechanisms come in handy. Setting x coord trafo/.code={\pgfmathparse{\pgfmathresult/60}} transforms your data from seconds to minutes on the fly, so the tick labels will be placed every minute (or at integer multiples of minutes, depending on the available space). To display the tick labels in seconds, ...


8

I removed /pgf/number format/fixed zerofill Code \documentclass[margin=1cm]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ height = 10cm, % standard 10cm width = 15cm, % standard 10cm xlabel = {$N$}, ylabel = {$e_h$}, grid=both, major grid style={black!50}, ...


7

The coordinate system of the axis is not the same as that of the underlying tikzpicture, so when you add a \draw outside the axis you cannot expect the coordinates to correspond to those inside the axis. Instead, use \pgfmathsetmacro{\N}{4}; \pgfplotsinvokeforeach{\N,...,0}{ % special looping defined by pgfplots \draw [line width=0.15mm, red] (#1/\N, ...


7

This has room for improvements, but as a quick hack. The code has comments where I changed things, ask if there is anything that requires further explanation. \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=center, grid={both}, % changed clip=...


6

Your problem is that you have \begin{axis}[...][...] LaTeX reads only the options in the first pair of brackets, everything in the second pair is ignored it seems. Your xlabel is in the second pair. Here is a working code. I commented out the x label style, but I also changed the coordinates for it. And I moved the legend, and commented the ylabel and ...


6

According to the manual the shown log basis is 10 when the used log basis is e. To overcome this issue we simply provide the number of e to log basis y and replace the default #1 of log number format basis to e. % used PGFPlots v1.14 \documentclass[border=5pt]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{semilogyaxis}[ ...


6

See : Placement of scale tick labels in pgfplots Below I make attempts with the following : every x tick scale label/.style={at={(rel axis cs:1,0)},anchor=south west,inner sep=1pt}, (left) and (right) every x tick scale label/.style={at={(xticklabel cs:1)},anchor=south west}, The output The code \documentclass{standalone} \usepackage{...


6

Here is an answer with somehow automated way using let syntax for coordinates and intersections for the calculations: \documentclass{article} \usepackage{tikz} \usetikzlibrary{intersections,calc} \begin{document} \begin{tikzpicture}[scale=2] \draw[->] (0,0)--(4,0) node[below] {$t$}; \path[name path=Vert,draw,->] (4.5,1)--(4.5,3) node[below,rotate=90] ...


6

Try the following. It fixes your "not-calculations" (braces do not equal calculation) and wrong syntax for \foreach. \documentclass{article} \usepackage{tikz} \begin{document} \pagenumbering{gobble} \begin{tikzpicture} \pgfmathtruncatemacro\start{2010} %Start year \pgfmathtruncatemacro\ende{2018} %End year \pgfmathtruncatemacro\differenz{\ende-\start} \...


6

axis x line shift shifts x axis down, and a negative number shifts it up. From y min=10 up to 20 gives -10. \documentclass[margin=3mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.16} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=center, axis x line shift=-10, xmin=0, ymin=5, ymin=10, ...


6

Welcome to TeX.SE! (Torbjørn T. has been a bit faster than me...) The problem is that your \foreach loop is run in a place where coordinates don't correspond to what you think. You can try adding: \draw[green] (1,0) circle (1pt); after your loop and you should understand that abscissa 1 in the TikZ xyz coordinate system doesn't correspond to abscissa 1 ...


6

The trick is scale only axes, which applies the dimensions only to the axis (when you add ticks, titles and so on the bounding box of the graph will be bigger, of course). \documentclass[]{article} \usepackage{pgfplots}\pgfplotsset{compat=1.13} \begin{document} \begin{tikzpicture} \begin{axis}[ xmin=0, xmax=1, ymin=0, ymax=1, ...


6

I think that it is sufficient to change the domain of the plotted functions. Specifically, I changed domain=-2*pi:2*pi to domain=0:2*pi. If you also don't want the extra length of the main axes, remove the enlargelimits option. For my personal taste, I'd rather use a legend than arrows connecting the labels to the curves ;) \documentclass[11pt]{article} \...


5

Everything works, if you use all needed packages... . Or do you have further questions and problems? \documentclass[10pt,a4paper]{article} \usepackage{tabularx} \usepackage{pgfplots} \usepgfplotslibrary{units} \begin{document} \begin{table}[!h] \caption{ Convergence NL8 on TTP and UTTP} \label{courb1} \begin{tabular}{cc} \begin{tikzpicture} \begin{axis}[ ...


5

Here is a suggestion using \label and \ref for the small images in the legends. \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.15} %\pgfplotsset{compat=1.3} % also works for me %\pgfplotsset{compat=1.8} % also works for me \begin{document} \begin{tikzpicture} \tikzset{ legendmatrix/.style={% style for legends draw,% draw a ...


5

I found a solution, maybe not the optimal one, but it allows to generalize. In (axis cs: {(1.5)*cos(\x)}, {(1.5)*sin(\x)}) in the frame inside scope one can substitude any polar equation in the form r(\x) instead of (both) 1.5. \documentclass{article} \usepackage{pgfplots} \usetikzlibrary{arrows, intersections, fillbetween} \begin{document} \begin{...


5

Add every inner x axis line/.append style={stealth-stealth}, every inner y axis line/.append style={stealth-stealth}, at the end of your axis options, just after the legend pos=outer north east, and just before the ] See section 4.9.9 of the current reference manual. If you are happy with them both being the same, you could just set a single key (as ...


5

You don't need to use explicitly multido– just have to use the \psaxis command, with the relevant parameters: \documentclass[11pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{pst-plot, auto-pst-pdf} \begin{document} \fbox{\begin{pspicture*}(...


4

I think there are several ways of doing this. One way would be to use y expr={ifthenelse(\thisrow{z}==0,\thisrow{y},nan} instead of y=y. \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.14} \usepackage{filecontents} \begin{filecontents*}{DATA.csv} x,y,z 0,0,0 0,0,1 1,1,0 1,1,1 2,2,0 2,4,1 3,3,0 3,9,1 4,4,0 4,16,1 5,5,0 5,25,...


Only top voted, non community-wiki answers of a minimum length are eligible