New answers tagged

1

Since pgfplots has a two phase workflow, first collect and queue and second do the visualization non plotting commands need to be collected in the right order if depends on the previous commands. Otherwise they can be prematurely executed as happened here. Inspired by \pgfextra (I think), there is a similar command in pgfplots which is \pgfplotsextra that ...


2

Just use the optional argument of tikzpicture and give the color name there. Other options can be set there as well, see the dashed option, but I don't think that will should be set globally. \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture}[blue, dashed] \begin{axis}[ ...


2

Partial solution (I skipped the contour level plots to simplify, let that as an exercise for the braves): Using the three-way if (boolean)?(value if true):(value if false) and the special "number" NaN (not-a-number), and using the option unbounded coords=jump you can do the following: \addplot3 [surf, unbounded coords=jump] { (x-2)^2+(y-5)^2<9 ? ...


1

The best solution is probably to use this trick \edef\temp{ \noexpand\coordinate (A) at (axis cs: \Test,\Test); } \temp which is also needed in other circumstances when dealing with the axis env. Basically we ask to have the \Test macro expanded before the coordinate is defined, not when axis later typesets it.


4

Your MWE produces the following warning: Package pgfplots Warning: running in backwards compatibility mode (unsuitable tick labels; missing features). Consider writing \pgfplotsset{compat=1.13} into your preamble. If you are running into problems you should always have a look at the log file. So in your case adding \pgfplotsset{compat=1.13} ...


3

Here is a suggestion using point meta=explicit symbolic, nodes near coords and every node near coord/.append style. \documentclass{standalone} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=newest} \pgfplotstableread{ 1 10 0.84 50 0.75 10 0.22 30 0.24 2 40 0.38 60 0.96 15 0.42 90 0.28 3 ...


1

With Chrisitan's help and a lot of searching around I managed to get it working! The definition: \def\tvalues{{53,125,172,248,286,338,415}} % N_i^1(t), param 1: t, param 2: i \pgfmathdeclarefunction{bsplinebase}{2}{\pgfmathparse{and(#1>=\tvalues[#2], #1<\tvalues[#2+1])}} % N_i^k(t), param 1: t, param 2: i, param 3: k with k > 1 ...


3

If you add point meta=explicit symbolic to the axis options, you can manually specify the labels texts for nodes near coords, using the syntax \addplot coordinates { (x,y) [label text] }; With legend columns=3, and the standard colors, because I didn't feel like defining five new colors: \documentclass[border=5mm]{standalone} \usepackage{pgfplots} ...


3

The primary difficulty appears to be a weakness of the floating point unit in TeX -- it appears to be unable to handle the array syntax. Deactivating it by means of use fpu=false works. Note that you code contains no domain argument -- your x argument is sampled with the default domain -5:5. Adding both + some style changes (that I forgot to remove while ...


1

As of pgfplots 1.13, this works without any modifications, i.e. simply running pdflatex -shell-escape file.tex twice results in the desired output. Here is a reduced minimal without the extra image.tex (but otherwise identical), compiled with pgfplots 1.13 and pgf 3.0.1: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.10} ...


7

Spaces. If you look carefully at the error message you see it refers to the symbolic coordinate called ' sphinx3', i.e. with a space first. In the list of symbolic y coords leading spaces are stripped, but this does not happen in the coordinate list for \addplot. So all you have to do is to change from (132, sphinx3) to (132,sphinx3). You might also want to ...


6

One possibility is xtick={-1,0,...,4}, xticklabel={ \ifdim\tick pt=-1pt \else \ifdim\tick pt=4pt \else \axisdefaultticklabel \fi\fi}, ytick={-4,-3,...,4}, yticklabel={ \ifdim\tick pt=-4pt \else \ifdim\tick pt=4pt \else \axisdefaultticklabel \fi\fi}, Code: ...


7

This is actually described in the manual for pgf/TikZ. See section 92.1 Changing display styles (for v3.0.1a, dated August 29, 2015). You're almost there in fact, just change the number formatting option for the yticklabels to /pgf/number format/.cd,sci,sci e. If you want a capital e, use sci E instead. \documentclass[border=4mm]{standalone} ...


1

Your squareroot parenthesis terminate the command prematurely. You need to hide it via braces (u*cos v,u*sin v,{sqrt(25-u*u)} );


1

Remove skip first n=1 from the \addplot table commands. If there is no header=false option for table, \addplot table uses the first row of your data file as column names. Code: \begin{filecontents*}{a.txt} Group Real Imag Cable {VSC P-mode} {VSC Vdc-mode} A -1.2739095e+02 -3.3612954e+02 4.9822998e-01 4.9309456e-01 ...


2

Edit: For an axis of arbitrary width, you can compute the width and store that value as described in this answer. Combining that approach with a new command (which I call \bgimage), you can insert a background image with width equal to the axis width. In the example below I've duplicated the plot to the right, but made it smaller to show the image scales ...


2

A workaround could be to use forget plot and \addlegendimage. \documentclass{standalone} \usepackage{tikz,pgfplots} \usetikzlibrary{decorations.markings} \pgfplotsset{compat=1.12} \tikzset{test decoration/.style={ postaction={ decorate, decoration={ markings, mark=between positions 0.5 and 1 step 10mm with {\node {test};} } } }} ...


3

You mean something like the following? (Have a look at the comments in the code to find out how it works.) \documentclass[border=2mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.3} \begin{document} \begin{tikzpicture} \begin{axis}[ xlabel={$x$}, ylabel={$y$}, xtick={-4,-2,...,4}, % place some extra x ticks ...


1

Did you try to rerun Latex? For the first run I get the warnings LaTeX Warning: External picture 'pdfimages/Latex1' contains undefined references on input line 6. and LaTeX Warning: There were undefined references. After a second Latex run the warnings clear and I get:


3

In your code you have to add the segment A2 to sequence: sequence=A0 -- B1 -- A2 Or you use the newer version of the syntax: sequence={L1 -- R2 --L3} Code: \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \usepgfplotslibrary{fillbetween} \pgfmathdeclarefunction{gauss}{2} ...


0

Here is a (not so great) solution/workaround. \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{fillbetween} \pgfmathdeclarefunction{gauss}{2}{\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[domain=0:10,samples=100,height=6cm,width=10cm, ...


1

According to your comment in mirkom's answer ... if you are a R user, why not do it with knitr? \documentclass{article} \begin{document} A nice scatter plot in \LaTeX: <<echo=F, dev='tikz', fig.width=6, fig.height=6>>= read.csv("file1.csv") -> x plot(x,type="l",xlab="fractions",ylab="Phospho hits", col="blue", lwd=2) @ \end{document}


0

Because it exceeds the memory. In the first csv you've got 39768 rows, which are a lot! There are two ways: Compile your document with lualatex (takes 8 seconds on my computer) Use this decimated csv with "only" 3060 points obtained from your old csv and compile with pdflatex (takes about 2 seconds): Can you see any difference? I don't! To reduce ...


2

So this is just a starting point but almost all necessary ingredients are nicely explained in the pgfplots manual. \documentclass[border=3mm]{standalone} \usepackage{pgfplots} \usetikzlibrary{intersections} \usepgfplotslibrary{fillbetween} \pgfplotsset{compat=1.13} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=left, xtick={0.5}, ...


3

Instead of using pgfplots to evaluate the expression you could use l3fp which guarantees full 16-digit floating point precision. Also, always use period as the decimal separator. \documentclass{article} \usepackage{pgfplots,xparse} \ExplSyntaxOn \DeclareExpandableDocumentCommand \eval { m } { \fp_eval:n { #1 } } \ExplSyntaxOff \begin{document} ...


2

When I understood your question right, you where on the right track. Have a look at the comments in the code for more details. \documentclass[border=2mm]{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{ % create a new style for the "curved line legend" /pgfplots/curved line legend/.style={ legend image ...


1

It does not work in your MWE because you are overwriting it by also giving the option nodes near coors to the \addplot command. Remove the latter one (or specify format here), and it will print. I added a thinspace before the percentage sign, although it can also be recommended to load the siunitx package and let that format and typeset the values for you. ...


1

Do you mean this? \documentclass[border=2mm]{standalone} \usepackage{color} \usepackage{pgfplots} \pgfplotsset{ compat=1.3, } \usepackage{tikz} \begin{document} \begin{tikzpicture} \begin{axis} % use this \foreach variant to cycle through the number of items \pgfplotsforeachungrouped \n in {1,...,10} { % ...


1

If you place the legend with \legend{...} instead of \node at (leg) {\pgfplotslegendfromname{grouplegend}}; there is another possibility that requires less changes in the code of your of (group-)plots in order to bring the legend below your plots. Furthermore, you can easily change the order of other elements, too. First, you have to define a new desired ...


3

You should check the syntax in the pgfplots manual: \documentclass{article} \usepackage{pgfplots} \usepackage{tikz} \begin{document} \begin{tikzpicture} \begin{axis} \draw[->,thick] (-0.5,0) -- ++(11,0) node[below left]{$t$}; \draw[->,thick] (0,-0.5) -- ++(0,7) node[below right]{$s(t)$}; ...


3

I think your problem is that you're not defining the width of the axis, so the default width is used. Looks like your lines are 6cm wide, so set width=6cm. There are a number of other settings that would be useful I think, here is a modified axis environment with some comments: \begin{axis}[ hide axis, enlargelimits=false, % removes whitespace between ...


1

If you want to specify the step, i.e. the interval of your ticks, you can also use the xtick distance-option. Refer to section 4.15 in the pgfplots manual, Version 1.13. As @Magpie pointed out, this one is easier to use than xtick if use have a large number of ticks you want to show. Code \documentclass{minimal} \usepackage{pgfplots} % example data file ...


1

For example, the line can be added by specifying the start and end coordinates: \addplot[very thick] coordinates {(4000, 0) (4000, 10000)}; Also I had to remove \pgfplotsdrawaxis, otherwise, the axis would have been drawn twice with slightly shifted components, see the first version of this answer. Full example: \documentclass{article} ...


4

As you already read from the comments, there is no HTML version for the manual (not for TikZ and not for pgfplots). But since many browsers use pdf.js as default viewer for PDFs, you may be able to link to internal links. Examples are: http://pgfplots.sourceforge.net/pgfplots.pdf#pgfp.axis (links to the axis environment) or ...


1

Your observation is correct: re-reading the same file multiple times scales considerably better than reusing a "file handle". The reason for this unexpected behavior is related to how programming in TeX works (or, in this case, does not work): there simply is no (efficient) array data type. The only way to implement array data types is to use the 'normal', ...


1

You can use axis coordinate systems to put regular tikz commands in the pgfplot axes. To bring the axes to foreground, I used the same method to fake the axes. This is not a general solution for other plots. If you reverse the y axis, the system will not be right handed, and people generally expect axes to be right handed. It is better to bring the x axis ...


0

You just can use the option draw position, see the manual in section 5.12, pp. 470. Edited Code: \documentclass[crop=false]{standalone} \usepackage{pgfplotstable} \pgfplotsset{compat=1.8} \usepgfplotslibrary{statistics} \makeatletter \pgfplotsset{ boxplot prepared from table/.code={ \def\tikz@plot@handler{\pgfplotsplothandlerboxplotprepared}% ...


1

One possibility is using option trim axis left for both tikzpicture environments: \documentclass[12pt]{article} \usepackage{pgfplots} \pgfplotsset{compat=1.12, width=12cm} \usepackage{showframe} \begin{document} \begin{center} \begin{tikzpicture}[trim axis left] \begin{axis}[axis lines = left, xmin=0, ymin=0] \addplot [domain=0:80] ...


5

With your code I got the warning Package pgfplots Warning: You have an axis with empty range (in direction ). Re placing it with a default range and clearing all plots. So if there is no plot inside the polaraxis environment set at least a value for ymax. \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{polar} ...


6

Multiple axis environments on top of each other can achieve your desired look. I chose the "outer" axes to be polaraxis, so that the spacing is on the outer circles is regular. There is a circle with degrees, and also two circles in portions of the wavelength (in both directions, towards generator and towards load). For the polaraxes, the xtick={...} option ...


1

Option pin can be replaced by label: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[ trig format plots=rad, axis lines = middle, enlargelimits, clip=false, ticks=none ] \addplot[domain=0:2*pi,samples=100,brown] {sin(x)} node ...


2

In the answer to the linked question, you will see xtick is used for positive values of x, while extra x ticks is for the negative values of x. You need to do something similar here. (I removed a couple unnecessary packages as well.) \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{figure}[tb] \begin{tikzpicture}[baseline] ...


2

You can transpose your table using \pgfplotstabletranspose and then use the solution given in Read boxplot prepared values from a table \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{width=7cm,compat=1.13} \usepgfplotslibrary{statistics} \makeatletter \pgfplotsset{ boxplot prepared from ...


2

Are you looking for something like this? \documentclass{standalone} \usepackage{pst-solides3d} \begin{document} \psset{unit=0.5} \psset{lightsrc=viewpoint,viewpoint=50 60 25 rtp2xyz,Decran=50} \begin{pspicture} (-1,-1)(8.5,10) \defFunction{F}(t){t cos 3 mul}{t sin 3 mul}{} \defFunction{G}(t){t cos 1 mul}{t sin 1 mul}{} \defFunction{K}(t){-4}{t}{} ...


5

There are several commands how you can achieve this. I have chosen to set an xtick at that position and then named it using xticklabels. You had everything right, but needed to add compat level to at least 1.11. That is very simple: Just add a node somewhere in the plot. For more details have a look at the comments in the code. ...


1

As Andrew has already mentioned in his comment to your question one solution would be to use the groupplots library of pgfplots, which I also present in my solution. But this approach can be adapted to three normal axis environments next to each other as well. Also for that you simply add some dummy lines to the first plot so all the entries you want to ...


2

If no height or width are specified, pgfplots uses the values of axisdefaultheight and axisdefaultwidth. If only one of these are specified (i.e., only height= or width=), the axes are scaled such that the aspect ratio of the default values is preserved. (See section 4.10.1 in the pgfplots manual) \documentclass{article} \usepackage{pgfplots} ...


2

You mean (simply) setting the width and height of the axis while ignoring the labels? \documentclass[border=2mm]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ % only scale the axis, not the axis including the ticks and labels scale only axis=true, % set `width' and `height' to the desired ...


2

You are not doing anything wrong. This is the expected output of your code. If you don't want the ticks to be scaled, either turn it of by adding scaled ticks=false to the second graph or in the preamble, or change the range, in which the numbers should be scaled by changing the values of the keys scale ticks below exponent and/or scale ticks above exponent. ...


3

You can use the xticklabel cs to position the x axis label: every axis x label/.style={at={(xticklabel cs:1)},anchor=south,red}, typeset ticklabels with strut, xlabel={$t$\strut}, The \strut inside xlabel and option typeset ticklabels with strut are used to ensure that the ticklabels and the label have the same height and the same depth. Code: ...



Top 50 recent answers are included