Hot answers tagged

22 votes

Change pgfplot auto tick distance

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{...
Stefan Pinnow's user avatar
15 votes

Symlog as axis scaling in PGFPlots

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 ...
marsupilam's user avatar
  • 6,373
15 votes
Accepted

Tikzpicture horizontal curly brace

\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 ...
AboAmmar's user avatar
  • 46.2k
13 votes

Shading a region between two polar curves

You could use intersection segments: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.15}% <- added!! \usepgfplotslibrary{fillbetween}% <- changed \begin{document} \begin{...
esdd's user avatar
  • 85.3k
12 votes
Accepted

Is there a way to place the x axis at a specific y value in PGFPlots?

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} \...
hpekristiansen's user avatar
12 votes
Accepted

Labeling axis in π increments

If you really want to stick with tikz (although I would recommend you use pgfplots for graphing),you can: Use \pgfmathsetmacro to compute the appropriate x-axis location as a multiple of pi. Use \...
Peter Grill's user avatar
9 votes
Accepted

Make axis intersection look nice with tikz and pgfplots

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. ...
Torbjørn T.'s user avatar
8 votes
Accepted

Tikz - loglog Scale with strange powers of 10

I removed /pgf/number format/fixed zerofill Code \documentclass[margin=1cm]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ height = 10cm, % ...
Milo's user avatar
  • 9,420
8 votes
Accepted

pgfplots: How to set true dimensions of axis

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} \...
Rmano's user avatar
  • 40.3k
8 votes

Labeling axis in π increments

Try this code: \documentclass[margin=.5cm]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[>=latex,scale=1.5] % first option for a grid like a millimetral grahic ...
Raffaele Santoro's user avatar
7 votes
Accepted

Pgfplot: axis label is not displayed

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. ...
Torbjørn T.'s user avatar
7 votes
Accepted

How to move axis multiplier to an appropriate position in PGFPlot?

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 ...
marsupilam's user avatar
  • 6,373
7 votes
Accepted

Tikz - Coordinates error when using draw with axis

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 ...
Torbjørn T.'s user avatar
7 votes
Accepted

How can I make this graph?

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} \...
Torbjørn T.'s user avatar
6 votes
Accepted

How to use e as base for log-axis labels?

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 ...
Stefan Pinnow's user avatar
6 votes
Accepted

Reflection of lines (rays) on function

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} \...
koleygr's user avatar
  • 20.1k
6 votes
Accepted

How to remove mantissa on semilogarithmic pgfplots graph (while retaining modifications for sans serif tick font)

If I understand correctly, you care about \mathsf, but not about the fixed point numbers. In this case, you can modify the way pgfplots typesets the math labels. To this end, pgfplots offers the ...
Christian Feuersänger's user avatar
6 votes
Accepted

Timeline, using foreach

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} ...
TeXnician's user avatar
  • 33.5k
6 votes

Tikz - Coordinates error when using draw with axis

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: \...
frougon's user avatar
  • 24.2k
6 votes
Accepted

How to plot only positive region in tikz

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, ...
Alessandro Cuttin's user avatar
6 votes
Accepted

How do I make a operation inside a node?

There are a few options here: Make the original numbers correct and do the calculations in the coordinates. This works because coordinates are already put through an expression evaluator. \foreach \...
Andrew Stacey's user avatar
5 votes
Accepted

PGFplot plot y over x where z=bar (comparable to SQL WHERE clause)

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} \...
Torbjørn T.'s user avatar
5 votes
Accepted

How to put the legend vertically in two axes coordinates in pgfplots?

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 ...
esdd's user avatar
  • 85.3k
5 votes

Shading a region between two polar curves

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(...
user35603's user avatar
  • 307
5 votes
Accepted

Tikz axis width and height keys do not get correct aspect ratio

I found the solution. It was clearly stated in the pgfplots manual, it was just a matter of finding it: Please note that pgfplots only estimates the size needed for axis- and tick labels. The ...
Mattia Tamellini's user avatar

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