# Tag Info

3

By default, TikZ nodes do not allow line breaks, but if you add the align=<left/right/center> key you can use \\. Hence, you can modify the legend style as below. \documentclass[border=4pt]{standalone} \usepackage{pgfplots} \pgfplotsset{ compat=1.12 } \begin{document} \begin{tikzpicture} \begin{axis}[ legend style={cells={align=left}} ] ...

5

This answer is based on g.kov's excellent answer, but uses the relatively new smoothcontour3 module to produce a nicer-looking surface. The smoothcontour3 module has been incorporated into Asymptote version 2.33 (released 11 May 2015, just a little too late for the Tex Live 2015 cutoff), so if you have that version or later, you should not need to download ...

1

Here's something that is most of the way there: It borrows heavily from my answer to How I can customize a legend on pgfplots? and the links within. The only thing missing is the horizontal line; if someone can build on my answer to achieve it, I'll happily delete it. % arara: pdflatex % !arara: indent: {overwrite: yes} \documentclass{standalone} ...

2

Here's an option using asymptote instead of pgfplots. Compile with pdflatex -shell-escape. \documentclass{standalone} \usepackage{asypictureB} \begin{document} \begin{asypicture}{name=spherical-harmonic-L-M-4-3} import graph3; import palette; size3(200,200,200); currentprojection=orthographic(4,1,1); //Parametric function R^2 --> R^3 for drawing ...

4

You should not shift the whole environment axis, but only the x axis labels themselves: \begin{tikzpicture} \pgfplotsset{ every axis x label/.style={ at={(ticklabel* cs:1.05)}, yshift = -7.5pt, anchor=west,}, width=14cm, every axis y label/.style={at={(current axis.above origin)}, anchor=north east, yshift = 1cm,} } ...

1

According to overleaf, this works \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \tikzset{adjust near node color/.code={% \pgfplotscolormapdefinemappedcolor\pgfplotspointmetatransformed% \definecolor{mapped node color}{rgb}{\pgfmathresult}% \pgfkeys{/tikz/text=mapped node color}% } } \begin{document} ...

0

If you read the section in the manual pgfplots.pdf about the patch option, you will find that the file is read three lines at a time. Each consecutive triple of points defines one triangle. That is, lines one to three define triangle one, lines four to six define triangle two, and so on. And this is what you get. If you want to use patch to draw a ...

0

My attempt to substitute the compiled result by tikzexternal.sty worked as soon as I defined \ifpgfpicture. The legend to name feature uses this switch which belongs to PGF. However, it should be save to define it and keep it at value 'false'. The following example worked for me: \documentclass{article} %\usepackage{pgfplots} ...

2

I could call this final: Since I am manually drawing the box, I can manually draw the ticks as well (with some lower-level trick), and avoid the crosses. I think the interior color is a nice touch, and I decided not to use a purely z-based color for the surface, as it looked too "fake" (too horizontal the gradient). \documentclass{standalone} ...

2

As a more principled approach, it turns out that the first solution from How to mark/label nth data point from file in pgfplots? also works for bar plots. The nice thing is that the xshift is taken care of automatically. \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \pgfplotsset{ node near coord/.style ...

2

Combining the two questions Annotate grouped bar plot and How to mark/label nth data point from file in pgfplots?, I figured out two possibilities: Either, you add nodes to the end of each \addplot command (before the semi-colon; see the second link above for more information about pos=), like: \addplot[style={blue,fill=blue,mark=none}]coordinates {(1, ...

3

You can remove the 3d box entirely, then draw parts of it yourself. \documentclass[border=5pt]{standalone} \usepackage{pgfplots} \usepgfplotslibrary{patchplots} \pgfplotsset{width=10cm,compat=1.10} \begin{document} \begin{tikzpicture} \pgfplotsset{set layers} \begin{axis}[ domain=-1:1, y domain=-1:1, enlargelimits=false, view={32}{22}, z post ...

3

It seems that you are using a configuration of your windows explorer that you should not. As I can see from your comments your windows explorer looks like this (I named your MWE 278597.tex after the running number in tex.stackexchange): See the missing .log file end in the empty red circle and the missing checked checkbox in the menu for ...

1

Do you mean this: For this I ad into axis option extra x ticks = {4e7}. Addendum: According to your comment: you need to enlarge xmax to 4'e7 or better to 5E7. Note: Maximal x value in your table is 40e6 or 4e7, so there is not sense to have xmax 10 times bigger (i.e.: 40e7). \documentclass[11pt]{book} \usepackage{graphicx} \usepackage{tikz} ...

6

Quoting from pgfplots.pdf: \addplot3 has a way to decide whether a line visualization or a mesh visualization has to be done. One has to search a little bit to find out how pgfplots does it in the case of a table input. To specify a surface, you have to tell \addplot3 which points are next to each other. The points are assumed to be in a matrix ...

2

By default, PGFPlots uses degrees for trigonometric functions, not radians. You can change this by setting trig format plots=rad: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} \begin{axis}[ trig format plots=rad, axis equal, hide axis ] \addplot [domain=0:2*pi, samples=50, black] ...

3

I guess that even though I specified xmin=-2, xmax=+2, ymin=-2, ymax=+2, pgfplots was still sampling outside this range. If I specify the domains explicitly using domain=-2:2 and y domain=-2:2, compilation works. Still, I really thought gnuplot was doing the calculation? So why was dimensions too large? \documentclass{standalone} \usepackage{pgfplots} ...

1

A far simpler solution would be to split the domains and offset the abscissa by a tiny amount. \pgfplotstableread{ Year OneCol SecCol ThirdCol ForthCol 2005 10 50 0 30 2005.0001 0 0 -10 0 2006 0 60 0 90 2006.0001 -40 0 -15 0 2007 ...

1

We had the same problem. The solution we have come up with is relatively non-intrusive. Your latex code stays the same, no additional special tags, but your x co-ordinates of your negative values changes a little bit. Since every x co-ordinate by default is stacked separately, we would plot the positives at e.g. 1, 2, 3, etc and the negatives at 0.999, ...

4

The problem appears to be an expansion issue in the interaction of pgfplots and \includegraphics. It can be reduced to the following minimal working example: \documentclass{standalone} \usepackage{graphics} \newenvironment{type}[1]{% \newcommand\getFile[1]{% directory1/#1/##1} }{} \begin{document} \begin{type}{directory2} File: ...

2

Temporary approach Add \makeatletter \gdef\pgfplots@ymin{0Y0.0e0]} \gdef\pgfplots@ymax{0Y0.0e0]} After \begin{axis}. As one might guess: \pgfplots@ymin and its friends are the registers that PgfPlots uses to calculated the limits of the plot. The min's are initialized to be 102147483645 and the max's are initialized to be -102147483645. Now, what you ...

5

If fixed it using the following options to the axis environment: scaled x ticks=base 10:6, /pgf/number format/sci subscript, Full working example below with output: \documentclass[tikz,border=10pt]{standalone} \usepackage{tikz} \usepackage{siunitx} \usepackage{pgfplots} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} ...

3

Changing your definition of the cycle a little bit by removing the final ,, which introduced an empty style for the 9th line and adding % for stability (didn't compile on my system without them) you get \pgfplotscreateplotcyclelist{mycyclelist}{% {UniBlau, line width = 2pt},% {UniGruen, line width = 2pt},% {UniOrange, line width = 2pt},% {UniRot, ...

2

You can also use the datavisualization library to plot your graph: \documentclass[tikz, border=5mm]{standalone} \usetikzlibrary{datavisualization.formats.functions} \begin{document} \begin{tikzpicture} \datavisualization [school book axes, visualize as line=sin, sin={style={thick, orange}} ...

3

In the solution below I've used the idea given by the author himself in Add custom entry into legend in pgfplot, together with the vertical alignment described in Correctly align vertical text on a baseline in pgfplots which gives: I have aligned the legend cells to the left and put the legend in the south east, but you can, of course, change that as you ...

5

I think it might be easiest to use PGFPlots for this, instead of the TikZ \draw plot mechanism. You can tell PGFPlots to use radians for trigonometric functions by setting trig format plots=rad: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ domain=0:2*pi, axis lines=middle, ...

6

Mixing normal tikz commands and PGFPlots axis environments can be a bit tricky sometimes. In this case, I think it's best to just stick with PGFPlots: you can tweak the axis appearance to give you the desired result. \documentclass[margin=10pt]{standalone} \usepackage{tikz} \usepackage{pgfplots} \usetikzlibrary{positioning,calc} \begin{document} ...

4

There may be an easier way to do this, but this is certainly the most adaptable. (Don't forget to run it twice.) \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.6} \begin{document} \begin{tikzpicture} \begin{axis}[name=boundary] \addplot {x};\label{pgfplots:c1r1} \addplot {x+4};\label{pgfplots:c2r1} \addplot ...

2

Just for completeness, here's what you could do with to[in=<angle>, out=<angle>, looseness=<value>]. The major downside is that you have to guess and improve the values, so you might need a few iterations until the result is satisfactory. Code \documentclass[tikz]{standalone} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} ...

1

A solution with TikZ and ..controls : \documentclass[tikz]{standalone} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{pgfplots} \usepgfplotslibrary{patchplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \draw[step=1.0,lightgray,thin] (-6,-4) grid (9,4); \draw[ultra thick,->,>=stealth](-6,0)--(9,0); ...

4

I would definitely pre-process the data file if you have 100,000 points and plot a trimmed data file. Eliminating every 10th point is not efficient and you risk eliminating spikes, despite still having 10,000 points. The below is a sample Excel spreadsheet (in xml format that should load into recent versions of excel) that shows one possible crude but ...

3

First, the coordinate system in a pgfplots axis is completely separate from that of the surrounding tikzpicture. Remember that an axis has a default width (240pt), and it will have that size regardless of the range. For example, if you have two axis environments, one with xmin=0,xmax=1 and one with xmin=0,xmax=10, they will still have the same width. Thus, 1 ...

5

From what I understand, you want to to generate a plot which is "close to" your screenshot, without requiring 100% accuracy. That sounds a lot like "make it smooth and ensure that it interpolates at some key points". While this can be done using manually computed splines, it is cumbersome as you need to fiddle around with the angles at the intersections. ...

6

As detailed in Pgfplots : can't plot some usual mathematical functions, the problem is that cube roots and other fractional powers are computed using logarithmic functions; as such, you can not produce (x-2)^(1/3) directly for negative numbers, but you can use abs(x-2)/(x-2)*abs(x-2) which is fine, provided that x\ne 2. % arara: pdflatex % !arara: ...

5

Use update limits=false. Modifying the bounding box is also possible, but not what you want in this context -- you want to change the entire appearance of the axis (unless I am mistaken). A solution is \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ no markers, trig format ...

3

Using dec sep align,precision=4, and adding specific styles for the first two columns may be what you're after. \documentclass{article} \usepackage{booktabs} \usepackage{pgfplotstable} \pgfplotstableread{ U(V) I(A) I/U 0.00 0.000 0 0.31 0.020 0.065 1.15 0.075 0.065 1.82 0.120 0.0659 2.73 0.178 0.0652 3.42 0.224 ...

1

Update 2015 Inspired by the use of nonlineartransformations in this recent answer, one nice way to do in straight-edge TikZ what I had in mind back when I posted the question is, for example, the following. \documentclass[border=5mm,tikz]{standalone} \usetikzlibrary{decorations.shapes} \usepgfmodule{nonlineartransformations} \def\fluttertransform{% ...

2

You can disable the grids with the "shader=inter" as suggested by @percusse . Then set the grids to whatever you want. Here is an example where the grids are each 1 (unit) distance for x and y. \documentclass[12pt]{article} \usepackage{amsmath} \usepackage{enumerate} \usepackage{tikz} \usepackage{xcolor} \usepackage{tikz-3dplot} \usepackage{hyperref} ...

2

The parameter "samples y=0" solved my problem. Here is the code and the figure: \documentclass[12pt]{article} \usepackage{amsmath} \usepackage{enumerate} \usepackage{tikz} \usepackage{xcolor} \usepackage{tikz-3dplot} \usepackage{hyperref} \usepackage{ifthen} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} ...

4

There might be more elegant solutions, but you can of course specify all the ticklabels, adding colour to some with \textcolor{<color>}{<ticklabel>}, see example below. \documentclass[border=4pt]{standalone} \usepackage{pgfplots} \pgfplotsset{ compat=1.12 } \begin{document} \begin{tikzpicture} \begin{axis}[ xlabel={X}, ...

4

\alph is a macro that prints the value of a counter as letters, and that causes a conflict, because it is redefined by you. Normally, the subcaption numbers are a, b, etc. and they are printed with \alph{subfigure}. When \alph is redefined to 2, the last value in the loop, \alph{subfigure} becomes 2subfigure. Call the loop macro something else, like \MyVar ...

0

Using a related answer about fpu formatting, I was able to use \ifnum in the case that my result was within the range of an int() [−16383.9998, +16383.9998]. The trick is to use \pgfmathfloattofixed on the \pgfmathresult. \pgfkeys{/pgf/fpu=true} \pgfmathparse{...do floating point math here (with an int() result)...} \pgfmathfloattofixed{\pgfmathresult} % ...

0

I have the same problem: Package pgfkeys Error: Choice '1.12' unknown in key '/pgfplots/compat/labels'. I am going to ignore this key. My system is Windows 7 enterprise 64bit + MikTeX 2.9 (64bit also) I tried the following steps - Delete and reinstall pgfplots package with the newest version - Uninstall and reinstall MikTeX with no avail, the ...

1

The problem is that title style does every axis title/append style, while in the default title style there is yshift=6pt. Use every axis title/.style={..} instead of title style={..}, that will redefine the style completely. \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[title=(a),every axis ...

1

While defining a colormap with xcolor like @Ignasi mentioned is a great idea and works fine, the colormaps of pgfplots have also many Matlab colormaps predefined, for example my favourite one, the hue colormap colormap/hsv. I extended an answer from this post, which was also brought to my attention by @Ignasi (so thanks alot for both answers). This yields ...

2

You can use [bar shift=0pt] to overwrite the original bar with one of a different color. \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ ybar, enlargelimits=0.4, symbolic x coords={A,B}, xtick=data, nodes near coords, bar shift=0pt ] \addplot coordinates {(A,7)(B,4)}; \addplot ...

6

It seems to be more easy to make sketch of spectra in pure TikZ: MWE: \documentclass[border=3mm, tikz, ]{standalone} \usetikzlibrary{positioning} \begin{document} \begin{tikzpicture}[ every node/.style = {font=\small}, specter/.style = {draw=red, very thick, rounded corners}, ] ...

7

The issue is a bug in PGF (in the floating point unit). A workaround is to write use fpu=false in the axis options, i.e. \begin{axis}[use fpu=false]. This workaround is valid for relatively small number ranges, only -- such as in your MWE. I will take care of the bug.

3

No idea why it happens, but a quick fix is to add date ZERO=2015-01-01. \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{dateplot} \pgfplotsset{compat=1.12} \usepackage{filecontents} \begin{filecontents*}{data.csv} date,value 2015-01-01, 3.2 2015-01-04, 6.5 2015-01-10, 6.8 \end{filecontents*} \begin{document} \begin{tikzpicture} ...

1

Found an answer by adding a second y axis with an invisible line; but maybe there is a more elegant way for doing this: \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \usepgfplotslibrary{dateplot} \pgfplotsset{compat=1.9} \usepackage{csvsimple} \usepackage{filecontents} \begin{filecontents*}{data.csv} date,days,value 2015-01-01, 0, 3.2 ...

Top 50 recent answers are included