# Tag Info

## New answers tagged pgfplots

4

I guess nodes near coords align=right does what you're after. \documentclass[border=2mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.9} \begin{document} \begin{tikzpicture} \begin{axis}[ width=6cm,xmax=0.4, % these were just for the example nodes near coords align=right ] \addplot+[nodes near coords,only marks, point meta=explicit ...

2

The *shape*s have various nodes defined. You can access those: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{shapes} \begin{document} \begin{tikzpicture} [ hexa/.style={shape=regular polygon, regular polygon sides=6, minimum size=1cm, %draw, anchor=south}, ...

5

You can tell pgfplots that the input is actually given in polar coordinates using data cs=polar. Pgfplots will automatically transform it to the output coordinate system: \documentclass{standalone} \usepackage{pgfplots} \usepackage{tikz} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=center, axis equal image, enlargelimits=true, ...

4

You can use compat/bar nodes=1.8 to make the error bar appear when using compat=1.9. \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{ compat=1.9, compat/bar nodes=1.8 } \begin{filecontents*}{dataTable.txt} xpos firsty secondy yerrdown yerrup 1 0 1 0.1 ...

3

You can use \drawplot option "forget plot" to keep the second plot (lower error bars) from appearing in the legend. \addplot[mark=*,blue,forget plot] plot[error bars/.cd, y dir=minus,y explicit] coordinates { (0,0) +- (0.5,0.2) (0.1,0.1) +- (0.05,0.1) (0.2,0.2) +- (0,0.1) (0.5,0.5) +- (0.1,0.5) (1,1) +- (0.3,0.4)};

3

You can define a new style called mylabel and shift it a bit vertically (y). This way you can just redefine the style, and all labels placed this way will look the same (3 and 4). With the tikzlibrary positioning you can do something like above right= and . See plots 5 and 6. Thanks at @HarishKumar for pointing that out. \documentclass{standalone} ...

16

You can transform the polar coordinates to cartesian using an x filter and a y filter. If you wrap those in a style like this: \pgfplotsset{ interpret as polar/.style={ x filter/.code=\pgfmathparse{cos(rawx)*rawy}, y filter/.code=\pgfmathparse{sin(rawx)*rawy} } } you can just add interpret as polar to your \addplot ...

2

The simplest solution is adding ytick=data. Then you only get lines corresponding to the data entries in the table. Alternatively you can specify ymin, ymax and perahps set enlarge y limits=true. \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.9} \begin{document} \begin{tikzpicture} \begin{axis}[ grid=major, point ...

1

I was able to produce the figure with the non-trivial colormap by computing the coordinates and colors externally and using the meta point information in pgfplots. Here is the code: \documentclass[tikz]{standalone} \usepackage{tikz} \usepackage{pgfplots} \usetikzlibrary{calc} \pgfplotsset{compat=1.8} \begin{document} \begin{tikzpicture} ...

3

You can set default values for the arguments of a .style 2 args in the same way that you set the default argument for a standard .style: \pgfplotsset{ custom style/.default={default value for first argument}{default value for second argument} }

3

You need to either explicitly specify which ticks to use (by saying ytick={1,...,3}), or specify to only label coordinates with data, by saying ytick=data: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \pgfplotstableread{ X question interactionhigh ...

1

With the help of http://guido.vonrudorff.de/pgfplots-discontinuities/ I managed to solve my problem. This way includes quite a bit of manual labor, but the result is what I wanted. The idea is to set the min and max range of the plot manually and then shift the ranges to the left so the gaps are closed. Of course, one has to manually set the labels on the ...

3

From my experience, the most efficient way seems to use only user defined colors, within the cmyk color space (affecting 0 to both magenta and yellow channels). For example, here are the definitions of the colors I used in my project. \usepackage[cmyk]{xcolor} \providecolor{PureDuotone}{cmyk}{1,0,0,0} \providecolor{DarkDuotone}{cmyk}{1,0,0,0.4} ...

7

pgfplots offers something on these lines. An example from the manual: \documentclass[border=10pt]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.9} \begin{document} \begin{tikzpicture} \begin{axis}[axis lines=none] \addplot[mesh,samples=1000,domain=-4*pi:4*pi,line width=2pt] {sin(deg(x))}; \end{axis} \end{tikzpicture} \end{document}

5

For that, you should use axis lines=left instead of axis lines=center: \documentclass{memoir} \usepackage{pgfplots} \pgfplotsset{compat=1.8} \begin{document} \begin{tikzpicture} \begin{axis}[ymin=0,ymax=1,xmin=0,xmax=1, xlabel=$\mathit{foo}$, ylabel=$\mathit{bar}$, axis lines=center ] \addplot[color=black, fill=black, fill opacity=0.5] coordinates { ...

2

You don't need \pgfgetlastxy for this, you can work directly with the intersections and with the calc library: \documentclass{standalone} %\usepackage{amsthm,amssymb} \usepackage{pgfplots} \usetikzlibrary{arrows,intersections,calc} \begin{document} \begin{tikzpicture}[font=\footnotesize] \begin{axis}[% axis lines*=none,axis y line=center, axis x ...

4

This is one possibility: \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.9} \begin{document} \begin{tikzpicture} \begin{axis}[ ybar, ymin=0, ymax=70, width=9.5cm, symbolic x coords={a,b,c,d,e}, xtick=data, bar width=15pt, axis lines*=left, ytick={0,10,...,60}, %changed code ...

1

Perhaps this approach is somewhat useful for you. The axes are put at the left and bottom and there is a minor grid for the y ticks. There are no symbolic x coords anymore and instead you now have explicit xticklabels. The double first and last ticks are gone. The chemical compounds in the ticks of the abscissa have been formatted by »chemformula« from the ...

1

I didn't like the output of \resizebox because the labels got distorted... so I thought changing the width would be better. There might be simpler solutions (using parameters I couldn't find), but here's one. I've used the showframe package to check the margins. \documentclass{article} \usepackage{t1enc} \usepackage{pgfplots} ...

1

The version info in MikTeX was wrong. Running the TeX file: \documentclass{article}\usepackage{pgfplots}\begin{document}\pgfplotsversion\en‌​d{document} the result shows the version number 1.8

1

And here is how to put a non-pgfplots style legend into pgfplots. \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[xmin=0,xmax=10,ymin=-5,ymax=5,name=border] \end{axis} \node[below left=1mm] at (border.north east) {\fbox{ \begin{tabular}{@{}r@{ }l@{}} \raisebox{2pt}{\tikz{\draw[black] (0,0) -- ...

6

This is a bug in pgfplots: log identify minor tick positions=true fails if x in [0.1,1] . I have fixed it in the developer version; will become part of the next stable.

0


6

This does look like a bug. As a workaround, you can set extra x tick style={ xticklabel={ \pgfmathparse{exp(\tick)} \pgfmathprintnumber[sci, precision=1]{\pgfmathresult} } } to print the correct label: \documentclass[11pt,titlepage,a4paper]{article} \usepackage{tikz,pgfplots,pgfplotstable} ...

2

You can use the draw position=<val> option to specify the location on x-axis. Code \documentclass[12pt]{article} \usepackage{pgfplots} % \pgfplotsset{compat=1.9} \usepgfplotslibrary{statistics} \begin{document} \begin{tikzpicture} \begin{axis}[ boxplot/draw direction=y, % xtick={1,2,3}, % xticklabels={1,2,5}, ] ...

0

EDIT: I missed the part where you requested the error printing. So this answer doesn't really answer the question. You can do it without using gnuplot: \documentclass{article} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{ compat=1.9, legend style={font=\footnotesize} } \begin{document} \pgfplotstableread{ X Y 1 1 2 4 ...

6

You can adapt the approach from Adding values to pgfplot legend: \documentclass[11pt]{article} \usepackage{pgfplots} \usepackage{pgfplotstable} \usepackage{filecontents} \begin{filecontents}{data.dat} 1 3 2 5 3 4 4 8 5 9 6 8 7 10 8 12 9 10 10 11 \end{filecontents} \begin{document} \begin{figure}[h!t] \centering \begin{tikzpicture} \begin{axis}[ ...

32

Edit A bug fixed (the outer equator midpoints was not calculated correctly, as pointed out by @Dror). MWE with Asymptote, file lattice.asy: size(200); import graph3; pen surfPen=rgb(1,0.7,0); pen xarcPen=deepblue+0.7bp; pen yarcPen=deepred+0.7bp; currentprojection=perspective(5,4,4); real R=2; real a=1; triple fs(pair t) { return ...

24

Are you thinking about something like this? \documentclass{standalone} \usepackage{asymptote} \begin{document} \begin{asy}[width=10cm,height=10cm] import graph3; import three; size3(200); currentprojection=orthographic(3,3,5); currentlight=light(gray(0.4),specularfactor=3,viewport=true, (-0.5,-0.25,0.45),(0.5,-0.5,0.5),(0.5,0.5,0.75)); int nb ...

3

Here's an answer using Asymptote: The code: \documentclass[margin=10pt]{standalone} \usepackage{asymptote} \begin{document} \begin{asy} settings.render=4; settings.prc=false; size3(8cm); defaultpen(fontsize(10pt)); import graph3; currentprojection=orthographic(5,2,3); real ymax = 3; real ymin = -ymax; real h(real y) { return sqrt(1 + (y/2)^2); } ...

3

It seems like you need to set decoration={name=none} to disable the decoration in this context: \documentclass{article} \usepackage{tikz} \usetikzlibrary{decorations,decorations.pathmorphing} \usepackage{pgfplots} \pgfplotsset{compat=1.9} \begin{document} \begin{tikzpicture} \draw node[draw, decorate, decoration={random steps}] (box) at (0,0) { ...

1

You can disable the decoration locally by setting decoration={name=none}: \documentclass[ a4paper ]{scrartcl} \usepackage{ tikz, pgfplots, amsmath } \usepackage[T1]{fontenc} \usepackage{ lmodern, textcomp } \usetikzlibrary{calc,trees,shadows,positioning,arrows,chains,shapes.geometric,% decorations.pathreplacing,decorations.pathmorphing,shapes,% ...

5

Since version 1.5.1 of PGFPlots, circle and ellipse radii are interpreted in terms of axis units (which is what you want). However, to maintain backwards compatibility, this feature isn't activated by default: you'll have to set \pgfplotsset{compat=1.5.1} (or higher). If you do that, you'll notice that you get an ellipse instead of a circle. That's because ...

3

There is a way to determine the radius in terms of the coordinates. Here is how. Assign a name to the points of interests. See \path (axis cs:x,y) coordinate (name); Assign them to commands \p1, \p2 and use veclen to determine the length of radius. calc from tikzlibrary is required Code \documentclass{article} \usepackage{amsmath} ...

0

Well after some consideration, since every \addplot3 I added kept appearing on top of the previous, I decided to "build" the graph from the back side to the front... Firstly I created this: \documentclass[border= 5mm]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} [ restrict z to domain=0:85,zmax=85,zmin=0, width=30 cm, ...

0

A different approach to this expansion problem. Using \pgfplotsinvokeforeach and a key defined with .code args (which is basically just a macro with delimited arguments). If you need the full power of \foreach you will either need to fake it inside the plot as explained in another example Code \documentclass[tikz]{standalone} \usepackage{pgfplots} ...

6

It is known that PGFPlots and \foreachs don’t go so nicely together because PGFPlots doesn’t process the plots firstly and then later draws them. (See PGFplots foreach equivalent to TikZ's with multiple variables separated by a slash for more information and explanations of the author of PGFPlot himself.) The package provides the macros ...

8

You have to expand \c (but I'd use a different name) before \addplot sees it: \documentclass{article} % TIKZ & PGF \usepackage[usenames,dvipsnames,svgnames]{xcolor} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usepackage{tikz} \usetikzlibrary{backgrounds, decorations.shapes, decorations.markings, shapes, patterns} % % % % % % % % CIRCLES % % % ...

7

This is the best I've found but I don't know if you'll find it easy enough. It's more or less the same effort required to define a color. \documentclass{article} \usepackage{tikz,pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \pgfmathsetmacro{\a}{1} \pgfmathsetmacro{\yshift}{1} \foreach \i in {0.25,0.5,...,1} {% ...

5

This is where xticklabel cs comes in handy: \documentclass{scrartcl} \usepackage{pgfplots} \pgfplotsset{compat=1.9} \begin{document} \begin{tikzpicture} \begin{axis}[ xlabel=$x$, ylabel=$y$, zlabel=$z$, after end axis/.code={ \draw [-stealth, thick, red] (xticklabel cs:0.2) -- (xticklabel cs:0.8); ...

1

As selwyndd21 advised, I applied the suggestions of this question and the tiks are now clearly visible: \documentclass[11pt, oneside]{article} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother \pgfplotsset{axis line on top/.style={ axis line style=transparent, ...

2

I use option {axis}[nodes near coords, x tick label style={rotate=45,anchor=east},] , maybe you could try in your favor. nodes near coords add the value for every bars. x tick label style={rotate=45,anchor=east}, rotate your label with angle 45. For the bar too wide, I think bar width=12pt is enough.

3

You can enter the coordinate system (cs) of an axis using axis cs. You should use this, whenever you want to add something to a plot, because pgfplots takes care of appropriate data scaling, logarithms, and even symbolic x coords. Have a look at the following, this might give you a good starting point. \documentclass{standalone} ...

6

There are different ways of getting rid of that big empty space: Decrease the overall width of the plot, moving the groups of bars closer together. You can do this by specifying a unit vector for the x axis. If you add more data, the plot will grow automatically. Keep the overall width of the plot, but move the groups of bars closer together. You can do ...

2

Specifying domain does not set the xmin, xmax etc. for the plot. It simply sets the function evaluation domain and then afterwards the min/max limits are set from the data. Due to rounding errors you can expect to see the behaviour you have. In general: Anytime you use groupplots and sharing axis domains you should specify x/ymin AND x/ymax. So your ...

2

The truly important issue here is that pgfplots assign by default 25 values to x in a range of -5 to 5 (independent of degrees or radians), this allows us to obtain by default 25 samples after evaluate the mathematical expression. Change the number of samples only allow us to have more values ​​to graph but only in that interval (-5 to 5). It is necessary to ...

6

A recommended solution with PSTricks just for fun! \documentclass[pstricks,border=12pt]{standalone} \usepackage{pst-plot} \begin{document} \begin{pspicture}(-.5,-1.5)(7,2) \psaxes[trigLabels,trigLabelBase=2,dx=\dimexpr\psPi cm/2\relax]{->}(0,0)(-.5,-1.5)(6.5,1.5)[$x$,0][$y$,90] \psplot[algebraic,linecolor=blue]{0}{TwoPi}{sin(x)} \end{pspicture} ...

8

As x is in radian, you have to use sin(deg(x)) to indicate \deg(x) in degrees in which the domain of trigonometric functions in TikZ is defined. \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} \addplot[samples=500,domain=0:2*pi]{sin(deg(x))}; \end{axis} \end{tikzpicture} \end{document}

1

As far as I can tell, the cause of the problem was the calculation involving numbers way above 10^5 which is when the internal calculator starts breaking, and hence pgfplot simply did not draw any points where that happened. I "solved" it by generating a table externally and loading it, works pretty well for me. \begin{figure}[ht] \caption{2-pole Lowpass ...

6

You have to specify the format of the input. In your case it's a file: \pgfplotstabletypeset[ignore chars={s},format=file]{heights.dat} The option is also explained at page 8 of the documentation

Top 50 recent answers are included