Tag Info

New answers tagged

2

Do you want something like this? \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{fillbetween} \usetikzlibrary{fadings} \tikzfading[name=myfading, bottom color=transparent!100, top color=transparent!0] \begin{document} \begin{tikzpicture} \begin{axis}[] \addplot[blue, name path=A,mark=none] coordinates {(-10,2) (8,2)}; ...


4

\documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} \begin{loglogaxis}[name=first,domain=1:1000,axis lines=left, enlargelimits=0.2,log ticks with fixed point,xlabel={$x$},ylabel={$y$}, ylabel style={at={(0,1)}, anchor=south,rotate=-90}, xlabel style={at={(1,0)}, ...


4

To avoids expansion issues with \foreach, pgfplots offers \pgfplotsinvokeforeach which can be used without problems; also, you can easily draw your lines from the curve to the axis using the function (no need to find intersections points); declaring the function from the beginning also simplifies the code: The code: \documentclass[border=5]{standalone} ...


1

From last paragraph on your question, I understand you want something like this: \documentclass[border=2mm]{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.10} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=left, scaled ticks=false, xtick=\empty, ytick=\empty, ymin=0, ...


2

The correct syntax (or at least a syntax which works) can be seen below: % arara: pdflatex \documentclass[border=5]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} \begin{axis}[% ,axis lines=left ,xtick=\empty ,ytick=\empty ] \addplot[samples=100,domain=0:10] ...


1

Here is one example \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} \begin{axis}[ axis x line=bottom, axis y line=left, xmin=0, xmax=2.5, ymin=0, ymax=2.5, xtick=\empty, ytick=\empty, xlabel=position $x$, ylabel=time $t$, ] \addplot [only marks,mark=*,nodes near ...


0

You can move the y label by adding a ylabel style key to your axis in the .tex file: \begin{axis}[ ..., ylabel shift={-10pt} ] You can do that directly from matlab by passing it as an extraAxisOptions to matlab2tikz: matlab2tikz(...,'extraAxisOptions','ylabel shift={-10pt}'); So you don't have to modify you're .tex file each time you replot


2

I am the author of the template Gabriel uses, and I do make use of overlay and remember picture for the cover page. But I'm pretty sure that the real solution to this problem is to make use of axis cs when specying the nodal points in the plot axis c.s. The pgfplots gallery show multiple uses of this. \node[...] at (axis cs:0.18,0.74,0.08) {...}; (I ...


2

You need to add table sub family to your style. Table options are required to be the subkey of /table/. Otherwise pgfplots can't understand it and thinks that maybe it is a TikZ key. That's why you have /tikz/meta in the error. Hence you need \pgfplotsset{ table/myStyleWithMeta/.style={ meta=Label, } } then it works


3

One possibility using legend image code/.code and \addlegendimage to provide the desired variation of the default line legend style: \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[legend entries={$f_1$,$f_2$},] \addlegendimage{no markers,green} \addplot [green,domain=-1:1,forget plot] {x}; ...


1

You can use it as follows: Don't use macro names starting with \the. That is a special case for TeX and might lead to mistakes that are very difficult to debug. \documentclass{article} \usepackage{pgfplotstable} \begin{document} \begin{tikzpicture} \pgfplotstableread[col sep=comma,header=false]{ ...


7

Use axis y line*=right, % and axis y line* = left too instead of axis y line=right, The starred version affects only the axis line leaving other things like positions of axis labels, tick lines etc. Since you are using \pgfplotsset inside the tikzpicture environment, it is better to add ylabel style={rotate=-90}, in it. To remove arrows from axis use ...


3

You were on right way ... you need just add style={rotate=-90}, to the second axis, or even better, put it with other common parameters into \pgfplotsset{...} . If you add here set layers, you will obtain borders aroun image without arrows. Slightly rearranged and simplified your code, which generate above image is: \documentclass[border=2mm, ...


2

The external PDF contains the drawing instructions for your legend, but since it is excluded from the bounding box, it is clipped away. I believe this is a limitation of PDF (or the way PDF's bounding box is generated in TeX). I think it used to work for dvips, but I might be wrong. A portable way (i.e. one which works for pdftex as well) is to use legend ...


3

Add axis x line*=bottom, ymin=0 to the axis options: \documentclass{scrbook} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ width = 12cm, hide y axis, axis x line*=bottom, height = 8cm, bar width=20pt, symbolic x coords={2010, 2011, 2012, 2013, 2014, 2015}, nodes near coords, ...


2

With xticklabel style={anchor=180-\tick} you can fix anchor of xticklabel on this reversed y axis, to drive away tick labels from the center you can add inner xsep=2mm. \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \usetikzlibrary{pgfplots.polar} \begin{document} \begin{figure} \begin{tikzpicture} \begin{polaraxis}[ y ...


5

Yes, this can be done (see example below). However, it's not clear that you really need a matrix here since all the required elements can be arranged as desired without using a matrix. One option would be to use pgfplots to draw your plots; box them (a precaution to avoid the plots from inheriting settings from the "outer" tikzpicture) and then use the ...


5

Improved version To have finer control, you can use Caramdir's answer to Drawing on an image with TikZ. The idea is to place the picture so that the lower left corner is at the origin of the TikZ coordinate system; a helper grid is added (See Jake's answer to the same question) just to easily visualize coordinates during the placement of other elements: ...


0

With key scale=0.2 (or what will convince you) you can reduce size for every linetext \documentclass{article} \usepackage{float} \usepackage{graphicx} \usepackage{pgfplots} \pgfplotsset{width=\textwidth, compat=1.12} \begin{document} [...] \begin{figure}[H] \centering \begin{minipage}{.32\textwidth} \def\callforme#1 {% \pgfplotsset{ticks=none} ...


1

Here's my attempt: I had to change some values, e.g. the distance between the gray rectangles, in order to have enough space. To better approximate the rollercoaster path you can use .. controls () and () .. or [out=<angle OUT>,in=<angle IN>]; I tried with the latter, even if with controls one is able to define complex paths more easily (but ...


2

You can use the after end axis/.code option and a foreach loop to read the file line by line. The maximum number of lines, asterisks and the maximum y-value are calculated using pgfplotstable. \maxvalue{barexample.txt}{yval} \maxasterisk{barexample.txt}{sig} \pgfplotstableread{barexample.txt}\myresult \pgfplotstablegetrowsof{\myresult} ...


2

You can use \raisebox to move box containing y tick label, for x tick label you can use as you mentioned \quad or moving the two x tick label with \kern \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.10} \begin{document} \begin{tikzpicture} \newcommand\CONSTH{326.4887} \newcommand\CONSTS{205.0669} ...


10

You can use pgfplots. \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} \begin{axis}[domain=0:10,scaled ticks=false,ymax=2000,ymin=2,minor tick num=1,xlabel=$x$, ylabel=$f(x)$] \addplot+[no marks,thick] {x^3}; \addlegendentry{$x^3$}; \addplot+[no marks,thick] {x*(2)^x}; ...


1

The acrotex packages that are loaded by the pgfplots.clickable library forget to load the calc package, which is needed in edvipdfm.def, see, for example, line 25 \setlength{\@tempdima}{\eq@rectH+\ef@border@adj}% You solve your issue by loading calc before pgfplots: \documentclass{article} \usepackage{calc} \usepackage{pgfplots} ...


0

As mentioned @JohnKormylo,l exact the same size of images you can obtain with group plot. Since this is inconvenient solution for you, there is not much other option as I mentioned in my comments. With declaring width and height of images, where you should care that they are narrower than text width you obtain almost the same their size. Another care should ...


5

Include domain=0:30. The default domain is -5:5, thus your plots will stop at x=5. \documentclass[paper=a4,12pt,version=last,landscape]{scrartcl} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{pgfplots} \usepackage{color} \begin{document} \begin{tikzpicture} \begin{axis}[ width=10cm, height=7.5cm, xmin=0, xmax=30, ymin=0, ymax=100, ...


0

You can try something like: \begin{figure}[h] \centering \hspace*{\fill}% \subfloat[]{% \resizebox{0.45\linewidth}{!}{\includegraphics{./fittingcurve/ST039LIMD5.pdf}}} \hfill% \subfloat[]{% \resizebox{0.45\linewidth}{!}{\includegraphics{./fittingcurve/ST018LIMD100.pdf}}} \hspace*{\fill}% \caption{} \end{figure}


3

TeX expands \thisrow{col2} to -2, so what's eventually seen is -2^2 which is, according to the usual conventions, -4. The same in the other cases. Adding parentheses, as follows, \documentclass{standalone} \usepackage{pgfplots} \usepackage{pgfplotstable} \begin{filecontents}{data.dat} col1 col2 -1 -2 0 -2 2 -3 \end{filecontents} ...


1

Here's an approach using pgfplots in combination with the sagetex package (to handle the necessary calculations that percussse mentions). The calculations are carried out by a computer algebra system, Sage, with the integral calculated by f(t1) = integrate(x^2,x,t1,3) and then y coordinates for plotting are determined by y1_coords = [(f(t1)).n(digits=6) for ...


2

You can draw this shape with tikz-3dplot. This is the final result I've added scale variables in x and y data so that you can change them. % scale your data \def \yscal {0.5} \def \xscal {2} Change them if you want to zoom in or out. This is the code for your case. \documentclass{article} \usepackage[table,dvipsnames]{xcolor} \usepackage{tikz} ...


11

It is also easy with pgfplots \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} \begin{axis} \addplot+[domain=0:360,samples=101,no marks] ({sin(x)},{cos(3*x)}); \end{axis} \end{tikzpicture} \end{document}


3

pgfplots uses library fpu for better precision by default, which has a different internal number format. Therefore \pgfresult is not 1 or 0 anymore and \ifnum cannot be used. \tikzset{fpu} \pgfmathparse{int(0)}\show\pgfmathresult \pgfmathparse{int(1)}\show\pgfmathresult The lines show 0Y0 for zero and 1Y1 for one. In this case, the whole math can be put ...


2

Delete the trailing comma from here: \foreach \x / \y in {0/0,5.65/2.65,3.12/0.16,0.83/0.03,0.20/0.03,} otherwise, TikZ attempts to place something on an empty coordinate. The complete code: \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ xmin = -1, xmax = 6, ymin = ...


1

I found this non-obvious to find out, but there is a plot "type" or whatever the name is, which means, this will work: \begin{tikzpicture}[every plot/.append style={very thick}] Or \begin{tikzpicture}[every axis plot/.append style={very thick}] Or \pgfplotsset{every plot/.append style={very thick}}


3

The automatic x ticks are suppressed by the special value \empty: xtick=\empty \documentclass[paper=a4,12pt,version=last,landscape]{scrartcl} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ scale only axis, xmin=-5 ,xmax=105, ymin=0,ymax=10, axis y line*=left, axis x line*=bottom, xlabel=, xtick=\empty, ...


3

This should fix your problem: \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \usepackage{pgfplotstable} \usepackage{filecontents} \begin{filecontents}{data.dat} fname foo one 1 two 2 three 3 \end{filecontents} \begin{document} \pgfplotstableread[col sep=space]{data.dat}\datatable \begin{tikzpicture} ...


3

This answer only uses TiKZ (without "extensive declaration in the preamble"). Lines are drawn with a foreach command and a list of coordinates "1/0.25,2/0.375,3/0.5,4/1,4.5/1" Labels are manually positioned and different scales for x and y axis are adjusted with tikzpicture option y=2cm. \documentclass[tikz,border=2mm]{standalone} \usepackage{lmodern} ...


4

You can use the datavisualization library from tikz to do this. The x-datapoints need to be adjusted (doubled) to get the plot like a const plot from pgfplots (perhaps there is also another built-in solution, didn't find it yet). \documentclass[tikz, border=5mm]{standalone} \usetikzlibrary{datavisualization} \begin{document} ...


5

% arara: pdflatex \documentclass{article} \usepackage{pgfplots} \pgfplotsset{% ,compat=1.12 ,every axis x label/.style={at={(current axis.right of origin)},anchor=north west} ,every axis y label/.style={at={(current axis.above origin)},anchor=north east} } \begin{document} \begin{tikzpicture} \begin{axis}[% ,xlabel=$e$ ...


3

The default coordinate system is axis cs in environment axis. It can be used for absolute coordinates. It is not suitable for relative coordinates, because the origin can be different from (0pt, 0pt). In the case of the example it is different and you would have to subtract the real origin. An easier way is using the axis direction cs, which is intended for ...


0

Okay, this solution is working fine indeed: Minimum Working Example (MWE): \begin{filecontents}{mydata.csv} X Y1 00:00.0 25 00:00.5 25 00:01.0 25.2 00:01.5 25.7 00:02.0 26.7 00:02.5 27.7 00:03.0 28.7 00:03.5 29.7 00:04.0 30.6 00:04.5 31.6 00:05.0 32.6 00:05.5 33.6 00:06.0 34.4 00:06.5 35.4 00:07.0 36.3 ...


6

The error ! Undefined control sequence. \pgfplots@label@ ->$c^\text {ref}$ l.26 \end{axis} indicates that the macro \text is not defined. This happens when you don't load amsmath package since the macro \text is defined by the package amsmath. With the following code: \documentclass[a4paper,10pt]{article} ...


4

You can use suitable coordinates and plot. \addplot+[draw=none,no marks,fill=olive] coordinates{(-2,-2) (2,-2) (2,2) (-2,2)}; Put this as the first line before plotting other two. \documentclass[a4paper,10pt]{article} \usepackage[utf8]{inputenc} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} ...


2

This label positionning occurs because of axis lines=middle in the gaxisonly axis style. According to the pgfplots doc, this parameter sets something like every axis x label/.style={at={(current axis.left of origin)},anchor=south west} Two way to avoid this: Use axis lines*=middle, which in your case will provide correct results Add something like ...


0

It was a bug (Fixed in version [2015/08/18]), see comment of AlexG. Here's the output (same code just updated version of animate package):


5

scaled ticks will put a comman scale at the end of the axis. You need fixed number formatting option. Use fixed in \pgfkeys{/pgf/number format/.cd,fixed, use comma} Full code: \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \usepgfplotslibrary{dateplot} \pgfkeys{/pgf/number format/.cd,fixed, use comma} ...


7

Besides fixing it by writing as sin(x), you can switch from degrees to radian with pgfplots 1.11 and newer: \pgfplotsset{trig format plots=rad} After adding it to your drawing, I got the sine function nicely displayed: This was first mentioned on TeXwelt by the pgfplots author in an answer to "Kann man bei pgfplots die Argumente trigonometrischer ...


3

Yes, animateinline calls a “sanitization macro” that changes all special characters (excluding braces and backslash) to printable characters. There are two ways around this. A save box \newsavebox{\animatecaption} % in the preamble \sbox{\animatecaption}{$\text{test}_{1}^{2}$} \begin{animateinline} [ controls, % Begin ...


2

\documentclass{article} \usepackage{pgfplots} \usepackage{subcaption} \pgfplotsset{compat=1.3} \usepackage[margin=1in]{geometry} \captionsetup{compatibility=false} \begin{document} \begin{figure}\small \begin{minipage}[b]{.5\linewidth} \centering \begin{tikzpicture} \begin{axis}[ybar, symbolic x coords={x1, x2, x3}, xtick={x1, x2, x3}, ytick={5, 4, ...


5

You are not doing anything wrong. It's just that you are using the default sample number and the default domain. Adjusting them gives you the result. \begin{tikzpicture}[ declare function={func(\x)=(\x>0.8)*(0.6*\x)+and(\x>0.6,\x<=0.8)*(2/3*\x)+(\x<=0.6)*(\x*0.75);} ] \begin{axis}[xmin=0,xmax=1,samples=351,domain=0:1, ...



Top 50 recent answers are included