New answers tagged

2

Here are a couple of possible ways to fix the problem. Add enlarge y limits={abs=0.4pt}, after the axis option ytick = \empty, Don't forget the extra comma after \empty. Use abs=0.4pt because this is the line width of the plot, so it removes the truncation or clipping at the top, but also adds a small amount of padding at the horizontal axis. A separate ...


3

You've gotten a good answer already, so this is just an alternative approach, which may be useful in other contexts. pgfplots has a list of styles that it steps through for each \addplot. There are several lists to choose from, see section 4.7.7 Cycle Lists – Options Controlling Line Styles in the manual, but you can also define your own. This is especially ...


5

mark options only affects the marks - not the style of the lines. \addplot+ adds options to those which would be used by \addplot, which would default to cycling through line styles, colours etc. So only options you explicitly override don't take effect. If you don't want the options to be appended, use \addplot[<options>] instead. For example: ...


1

Here is a suggestion using layers. If layer pre main is defined all the \tikzfillbetween stuff goes to this layer automatically. \documentclass{standalone} \usepackage{pgfplots} \usetikzlibrary{patterns,positioning} \pgfplotsset{compat=1.10} \usepgfplotslibrary{fillbetween} \begin{document} \begin{tikzpicture}[ thick, pathE/.style={% path E is used ...


0

If your data is going to be plotted in the order that it appears in the table and the index column is not used to adjust the order or position of the bars, you can simply use xtick = {1,...,20} where 20 is just an arbitrary number that's greater than the number of rows in your table. This will generate a tick position at every integer value of x between 1 ...


11

Not strange, consider where the function value is calculated, by setting mark = x: The default number of samples is 25, and 25 samples from -3 to 4 gives one sample at -0.0833 and the next at 0.20833. The asymmetry causes the problem you see. If you set the number of samples and the domain such that you get a sample exactly at zero, you should be fine. ...


0

If you do not have to compile this part every time, you could create a pdf file and include this via includegraphics ....just an idea...


0

Here's an alternative approach using Metapost and luamplib. This uses the standard buildcycle macro from plain MP to find the region bounded by the two curves and the axes. I've chosen to draw and label the axes "by hand" but you could also look at mpgraph to automate some of that if you wanted. Compile with lualatex or follow the links above to find ...


1

As i only want to do 2D-Plots, I can use the z coordinate as a temporary buffer for the meta value, if the viewing angle is set to be from the top. Probably not the most elegant way, but it works... Comparison linear / symlog colormap The Code of the colormap transformation \pgfplotsset{ symlog colormap trafo/.code={ \pgfkeysalso{% y coord ...


5

This works, but requires copious manual intervention. Note, in this case [ytick=data] would achieve the same effect, but in general you can't count on that. \documentclass{standalone} \usepackage{pgfplots} \usepackage{pgfplotstable} \usepackage{filecontents} \pgfplotsset{compat=1.12} \begin{filecontents}{data.dat} x y 4 -1e4 4 -1e3 4 -1e2 4 -10 4 -1 ...


7

Here is a different approach where we color the entire background using axis background/.style={fill=orange} Then colour the other parts as white. For this we name x and y axes using: x axis line style={name path=xaxis}, y axis line style={name path=yaxis}, and then add \addplot[fill=white] fill between [of=A and xaxis]; \addplot[fill=white] fill ...


8

fillbetween allows you to split the filling into the different segments made by intersections, and add individual styles to each, so you can do e.g. \addplot fill between[ of=A and B, split, every segment no 0/.style={pattern=north east lines}, every segment no 1/.style={fill=none}]; \documentclass{article} \usepackage{tikz,pgfplots} ...


7

You can use intersection segments: \fill[ intersection segments={ of=A and B, sequence={L1--R1[reverse]} }, pattern=north east lines, ]-- cycle; L1 is the first segement of the left path (in the example path A) and R1[reverse] is the reversed first segment of the right path (in the example path B). Code: ...


0

The TikZ picture tries to access the undefined \figurewidth and \figureheight macros to configure the image width. After definition and setting the lengths (please change the lengths at will) the compilation works. \documentclass[]{memoir} \usepackage{pgfplots} \usetikzlibrary{arrows,shapes,snakes, automata,backgrounds, ...


0

The problem is that you haven't considered what kind of values the expression 0.0172*x + 2.9971 will give you for x in the range [0,14] -- they will be between 2.9971 and about 3.24. But you have set ymin=50, meaning that the line is far outside the region you're plotting. I don't have your datafile of course, but If I remove those plots, and the ymin, ymax ...


10

run with xelatex or latex->dvips->ps2pdf \documentclass[border=5mm]{standalone} \usepackage{pstricks} \makeatletter \define@key[psset]{}{K}[0.5]{\def\psk@K{#1 }} \define@key[psset]{}{rDot}[0.5pt]{\pst@getlength{#1}\psk@rDot} \psset{K=0.5,rDot=0.1pt} \def\psChirikov{\pst@object{psChirikov}} \def\psChirikov@i{% \begin@OpenObj \addto@pscode{ /K ...


2

You were just missing a semicolon at the end of the \addplot line`. And by default just one plot is added from a file, so you need two, one for each series. Some other comments: If you want the legend entries displayed in a row, as in your screenshot, add legend columns=-1. I think there should be some more space between the xticklabels. You can for ...


18

Metapost will be much much faster than TikZ or pgfplots. Previous answers (see the edit history) used lualatex for simple inclusion in to a document using luamplib (as well as lualatex with TikZ for extra slowness). The following example shows how metapost can be used with pdflatex using the gmp package, although the file must be compiled with ...


2

I am forever thankful to both @johannes_B and @Torbjorn. Again, I would never have gone around it if it was not for their help. The problem I was finding was how to write ideas found online on a template. It seems that I was writing every user packages in the main.tex when I should have written it in a particular file in that e main.tex. After I had done ...


1

I'm sure you could figure most of this out by looking through the manual for a bit (there are a lot of examples in there), but here's one suggestion. \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \begin{document} \begin{tikzpicture} \begin{axis}[ symbolic x coords={Low age,High age}, xtick=data, ...


2

To draw the coloured square behind the plot, simply place the \fill before the \addplot. Usually stuff is drawn in the order they're added to the code, so by adding the \fill first it ends up on the bottom. To add the box with the text you can use something like this: \draw[->,shorten >=1mm,shorten <=1mm] (rel axis cs:0.5,0.5) ...


4

Here's my try. I couldn't find the font for the numbers, though, because I prefer the font in your example than the default in Latex. Output Code \documentclass[margin=10pt]{standalone} \usepackage{lmodern} \usepackage{tikz} \definecolor{lbluew}{RGB}{222,242,252} \definecolor{dbluew}{RGB}{186,229,250} \definecolor{lbluef}{RGB}{233,247,254} ...


1

Looking at the code of the groupplots library, I see that the style /pgfplots/group/every plot is added to each \nextgroupplot. So to only affect axes in groupplots environments, append to that style, e.g. \pgfplotsset{/pgfplots/group/every plot/.append style = { ylabel absolute, y label/.append style={yshift=0em}, } } \documentclass{article} ...


4

\documentclass[tikz,border=2mm]{standalone} \usetikzlibrary{shapes,fit,calc} \definecolor{lightblue}{HTML}{DEF2FB} \definecolor{darkblue}{HTML}{BCE5FB} \definecolor{lightbluetext}{HTML}{E6F7FF} \definecolor{darkbluetext}{HTML}{D3EFFE} \definecolor{bluetext}{HTML}{2E73A3} \definecolor{grey}{HTML}{AFAFAF} \begin{document} \sffamily\bfseries ...


0

As suggested in the comments, use the option z buffer = sort to correct the sorting in the data file. If you plot the function directly in pgfplots, the problem does not exist.... \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.8} \begin{document} \begin{figure} \centering \begin{tikzpicture} \begin{axis}[ title={$x ...


2

In this case, an easy solution is to use the attribute xticklabels from table, since the input data is in table format: \begin{tikzpicture} \begin{loglogaxis}[ log ticks with fixed point, xtick=data, xticklabels from table={data.dat}{input}, ] \addplot table[x=input,y=output] {data.dat}; \end{loglogaxis} ...


3

create your export file from your Gephi graph using TikzExport, then \documentclass{minimal} \usepackage{tikz} \begin{document} \input{Gephiit.tikz} \end{document}


3

I suggest switching to the tikzposter class, which is partly based on the fancytikzposter package. The former does not have the same problem. \documentclass[a0paper]{tikzposter} \usetheme{Rays} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=1.13} \pgfplotstableread{ S wQoS QoS 27 570 570 54 3098 5020 81 29578 36476 108 ...


5

There is no predefined thing. You have to convert it by hand. \documentclass{article} \usepackage{pgfplots} \usepgfplotslibrary{polar} \newcommand\subticks{0.30103,0.47712125,0.60205999,0.69897, 0.77815125,0.84509804,0.90308999,0.95424251, 1.30103,1.47712125,1.60205999,1.69897, 1.77815125,1.84509804,1.90308999,1.95424251, ...


1

A quick example with groupplots. \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \usepgfplotslibrary{groupplots} \begin{document} \begin{tikzpicture} \begin{groupplot}[ group style={ group size=1 by 4, % sets number of columns and rows in groupplot array vertical sep=0pt, % vertical distance between axes }, ...


2

here is my proposal, I am not satisfied but it should allow others to complete. I do not know what to write about tilting axes \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc,intersections} \begin{document} \begin{tikzpicture}[scale=2.5,transform shape] \def\nbdecade{4} \pgfmathsetmacro{\fin}{\nbdecade-1} ...


1

maybe I'm missing something here, but in your example (which is the example given in the pgfplots guide), the range is [1,10] and you have three bins: 1-4 (so includes values 1,2 and 3 if it was present), 4-7 (includes 4 to 6) etc.


2

It is a result of the legend style. You've placed the legend way outside the axis limits. The reason you don't see anything at all can be seen by adding \fill[red!20] (current bounding box.south east) rectangle (current bounding box.north west); just before \end{tikzpicture}. Essentially, the axis is at the bottom left of the tikzpicture, and the legend in ...


2

In a) I assume you meant the ticklabels. That modification can be achieved with xticklabel={\euro\pgfmathprintnumber\tick}, yticklabel={\euro\pgfmathprintnumber\tick}, To change the precision of the ticklabels, I added ticklabel style={/pgf/number format/.cd, fixed,precision=2,fixed zerofill, ...


2

The code you posted works fine here, you just forgot a multiplication sign (*) before the last x, and there's an extra ). \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=newest, grid=both, axis lines=middle, width=6cm, height=8cm, scale only axis, } \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines = left, ...


1

Using a scratch plot and adding some of the commands from the O.P. code: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest, grid=both, axis lines=middle, width=6cm, height=8cm, scale only axis, } \begin{document} \def\planck{6.6e-34} \def\light{3e8} \def\temperature{5800} \def\kB{1.38e-23} ...


2

You can use axis x line or axis x line* to choose which axis x lines should be drawn. Possible values are box (default), top, middle, center, bottom or none. While the starred version only changes the location of the axis the non starred version also affects some other keys. So you can use axis x line*=top to remove the bottom line. Code: ...


3

You're just missing one closing brace in the definition of northwestpoint. Note that for southwestpoint you have three closing braces at the end of the \pgfplotsset, but in northwestpoint there are two. Here's a slightly different version, which makes use of the fact that you can nest styles, and also prints the numbers in math mode, so you get proper minus ...


0

Why have you put all those options in every axis plot post/.append style? I'm not entirely sure what you're after though, but try the code below. \documentclass{article} \usepackage{pgfplots} \begin{document} \pgfmathdeclarefunction{poiss}{1}{% \pgfmathparse{(#1^x)*exp(-#1)/(x!)}% } \begin{figure} \begin{tikzpicture} \begin{axis}[ samples at = ...


0

I'm not sure what you have against coordinates, but if you just can't stand them for some reason, you could use local bounding boxes with calc. For example: \documentclass[tikz,border=10pt,multi]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \begin{scope}[local bounding box=plot 1] ...


3

This happens because, even though you're setting xmin=-1, xmax=1, the function is still evaluated over a much larger domain (-5:5). The samples outside the axis limits are just not displayed. This creates a lot of unnecessary overhead, so you should limit the domain by setting domain=-1:1: \documentclass{standalone} \usepackage{tikz} ...


3

I think this is a solution very close to what you want. It uses the spy library to apply the magnification. The grid on the "lens" node is applied using \pgfextra. I'm having a bit of unexpected issues with setting the ticks on that square node, I'll edit my answer as soon as possible. Output Code \documentclass[margin=10pt,tikz,multi]{standalone} ...


1

I am not sure if I understand what you want to do. With nodes near coords, point meta=explicit symbolic it is possible to set explizit labels for several bars \addplot[fill=red] coordinates { (test\_1,775)[\textcolor{red}{label}] (test\_2,5597) }; Code: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{width=15cm,compat=1.9} ...


1

Limiting expressions require a high resolution floating point computation which fpu tries its best to provide but still limited. You can help pgfplots by increasing the sample numbers (notice the slight artifact at the peak) . \begin{tikzpicture} \begin{axis} \addplot[draw=blue,trig format=rad,domain=-3*pi:3*pi,samples=701] {(sin(2*x) + sin(3*x) )/ ...


3

You have \addplot+[dashed,color=blue,mark=*,mark options=solid,{fill=markercolor}] so the only thing in mark options is solid, while fill=markercolor is a separate entry in the list of options, and applies to the plotted line, not the markers. You want to move that brace, so you have \addplot+[dashed,color=blue,mark=*,mark ...


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} ...



Top 50 recent answers are included