New answers tagged

1

This solution assumes that the sa file is tab separated. \documentclass[margin=0.3cm]{standalone} \usepackage{tikz} \usepackage{datatool} \usepackage{pgfplots} \usetikzlibrary{arrows.meta} \pgfplotsset{compat=1.13} \pgfplotsset{ytick style={draw=none}} \def\axisdefaultwidth{9cm} \def\axisdefaultheight{6cm} \pgfplotsset{every axis/.style={scale only axis}} ...


1

Here is the same answer as Rmano's one, but in Lualatex with everything in the same file: \documentclass[border=10pt]{standalone} \usepackage{pgfplots} \usepackage{tikz} \usepackage{pgf} \usepackage{luacode} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[xlabel=p1, ylabel=p1t, zlabel=p2t, tick style={draw=none}, xmin=-300, ...


2

Here is a MWE \begin{filecontents*}{data.dat} date, temperature 2015-12-21 00:00, 17.54 2015-12-21 00:59, 17.23 2015-12-21 01:58, 16.96 2015-12-21 02:57, 16.88 2015-12-21 03:56, 16.70 2015-12-21 04:55, 16.36 2015-12-21 05:54, 17.02 2015-12-21 06:53, 19.24 2015-12-21 07:52, 20.40 2015-12-21 08:51, 22.06 \end{filecontents*} \documentclass[margin=5pt]{...


2

I do not have your data, so I just made up some numbers which is nowhere near what you have, but it illustrates the point. This answers is stolen from Dr. Manuel Kuehner's pgfplots, plot options ignored when using “restrict expr to domain”. Output Code \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \usepackage{filecontents} \begin{...


3

The reason, as you guessed, is that you set the maximum value for your y as 7000000, that's 7 million. But your e value is 41930786, so 41 million, at least. So yes, it's out of range. If you want to have the current configuration and still have e to appear, even though it gets cut, then you can restrict the domain. Output Code \documentclass[margin=...


2

To fill the background of the ticklabels you can use ticklabel style={fill=white}. But the are drawn before the plots ... To change this order you can define and use a new layer set. \pgfplotsset{ standard/.style={ axis x line=middle, axis y line=left, ticklabel style={fill=white}, set layers=tick labels on top% use ...


3

Add xticklabel style = {fill=white}and set layers = axis on topto your axis : \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \begin{document} \pgfplotsset{ standard/.style={ axis x line=middle, axis y line=left, fill = blue } } \begin{tikzpicture}[] \begin{axis}[standard, domain=0:2,...


0

Could you check whether this helps: \begin{tikzpicture}[] \begin{axis}[standard, domain=0:2, xtick={1}, % xticklabels={label}, ] \addplot[blue] coordinates { (0,-1) (1,-1) (1,1) (2,1) }; \node[fill=white] at (axis ...


1

Is this what you want? \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture}[scale=2] \begin{axis} \addplot+[only marks] file[x index=0, y index=1]{baba.txt}; \end{axis} \end{tikzpicture} \end{document}


1

This shows how to put a 1 column legend on the right. It occurred to me that your legend comes from one plot instead of combining entries from multiple plots, which simplifies matters. \documentclass[margin=5mm]{standalone} \usepackage{pgfplots} \usetikzlibrary{matrix} \usepgfplotslibrary{groupplots} \pgfplotsset{compat=newest} \begin{document} \begin{...


1

I am not sure there is a typical or proper way to do it. Usually I put the plot in a picture or, as below, a tikzpicture and put a grid above it. Then it is easier to navigate. When started it is pretty quick to find the right coordinates for the axis. Below is an example of how to put it. If in a normal picture environment you can also use the graphpap ...


7

I would use a split approach, really -- I am posting this here because I am sure that someone with LUA skills will integrate it in a standalone LaTeX source. It happens I know python... and I will learn from the other answer :-) So I created this quick and dirty python script to find the intercepts, by linear interpolation: #! /usr/bin/env python3 # # ...


0

As percusse pointed out the problem might be outdated versions of tikz and pgfplots. However I got the result I wanted by a workaround: file data.txt : 1, 99 2, 120 3, 80 tex code : \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{figure}[h!] \centering \begin{tikzpicture}[scale=1] \begin{axis}[ ybar, ...


4

This is a common problem with pgfplots (or tikz in general), that you cannot round numbers prior to printing them. But here we need to fully-expandably round the numbers, which can be done with l3fp. I declared the macro \round[<precision>]{<expression>} which rounds expression to precision decimal digits. The precision argument is optional ...


1

Just before the first axis is finished you can record the values globally for the next axis via after end axis/.code key. \documentclass[border={50pt 10pt}]{standalone} \usepackage{pgfplots} \usepgfplotslibrary{units} \usetikzlibrary{calc} \newcommand{\ratioX}{2} \newcommand{\ratioY}{10} \pgfplotsset{ compat = newest, change x base, change y base, ...


2

Found an answer by digging in the PGFPLOTS manual, Setting the smith chart width, as it is circular to a set value, and setting the height and width of the rectangular plot made everything work out. \documentclass[margin=10pt]{standalone} \usepackage{verbatim} \usepackage{tikz} \usepackage{pgf} \usepackage{pgfplots} \usetikzlibrary{shapes,arrows,...


0

Well,if you have R and you admit knitr as LaTeX solution, then is easy: \documentclass{article} \usepackage{verbatim,xcolor} \begin{filecontents*}{A.csv} date,colA 2016-01-01,1 2016-01-02,4 2016-01-03,2 \end{filecontents*} \begin{filecontents*}{B.csv} date,colB 2016-01-01,2 2016-01-03,4 \end{filecontents*} \begin{document} <<echo=F,results='asis'...


3

It can be easily done by reordering your plots. First, all the data, then all the theory. Between data and theory you reset the pgfplots cycle list (i.e. shift by the number of theory plots) to have it step through it in the same order again. Reordering might seem tedious at first, but this way you will evade other problems such as having to skip legend ...


1

This worked for me, but am not sure if externalize is working. Anyway, I am assuming that \pgfplotslegendfromname does not use the aux file. \documentclass{article} \usepackage[width=18cm]{geometry} \usepackage{pgfplots} \usepgfplotslibrary{groupplots} \usetikzlibrary{pgfplots.groupplots} \usetikzlibrary{plotmarks} \usetikzlibrary{calc} \...


1

This is a bug introduced by lualatex shipped with TexLive 2016. The next version of pgfplots will fix the incompatibility (will be 1.14).


2

So this one is a bit tricky to solve from the doc's nodes near coords align in combination with visualization depends on should have been the silver bullet. Weirdly it fails. Instead one must combine visualization depends on with every node near coord/.append style as a work around. One must also include their data inline, as explained by @Symbol1, to ...


-2

i had the same error and could reduce it to the following package: fixmetodonotes. This interfered with transparency. By adding \usepackage{fixmetodonotes} to the above example, transparency got lost.


0

Just to add to this if anyone still has this problem, I found a pretty simple way to fix it. I was getting this error: TeX capacity exceeded, sorry [main memory size=5000000] I went through a lot of guides to increase the main memory and nothing was working :/ But I read a few articles where they talked about save_size instead of main_memory. I edited ...


4

with soft clip={domain=1.01:10}:


2

Answering to have this marked as an answer --- and to point duplicates here. It seems a bug. If you change the soft clip to soft clip={domain=100.01:3000} it will work:


2

The best way to combine graphics and plots is to save the coordinates inside the axis environment then draw the graphics outside. I adjusted \mL, \mW, and yshift to fit. \documentclass[border=5mm]{standalone} \usepackage{pgfplots} %\usepackage{tkz-euclide} \usetikzlibrary{patterns} \usepackage{filecontents} \begin{filecontents*}{data.csv} a,b,c 0,4,...


2

First you need to find out how large the \ref is in font dependent units like ex, or at least how large you would like it to appear. Then use \resizebox to scale it to that size. (graphicx is loaded with tikz.) \documentclass[14pt]{article} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \usepgfplotslibrary{external} % these commands take care if `...


1

I came up with partial solution. It simply iterate over every single row and compare it with previous one, drawing it only, if coordinates doesn't wrap around. However, it's not the fastest one (actually, it's slow as hell). Also, it doesn't support smooth lines yet, so if anyone knows better one, please share. \begin{tikzpicture} \begin{axis}[ height=...


4

xstep isn't defined by pgfplots, but I see it exists in TikZ, for modifying grids there. For your case you can just change xtick={-2,...,20} to xtick={-2,0,...,20}. Because the difference between -2 and 0 is 2, the numbers will be -2,0,2,4 and so on up to 20, instead of -2,-1,0,1 etc. Though of course, since your axis stops at 8, you could just as well do ...


1

It should work without any problems. \documentclass[]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \begin{document} \begin{tikzpicture} \def\mylabel#1{\tikz\filldraw[#1] (0,0)circle (3mm);} \begin{axis}[ xtick={-2,0,2}, xticklabels={\mylabel{red},\mylabel{blue},\mylabel{gray}} ] \addplot {x}; \end{axis} \end{tikzpicture} \end{document}


2

For the last two lines inside the axis environment you can also name the legend entry and position it relative to that. Line legend images are 0.6 cm by default hence you can tweak quicker. \addlegendimage{empty legend} \addlegendentry[name=l1,minimum height=5mm,]{} \end{axis} \node at ([xshift=0.35cm]l1) {Drink/Day};


2

You can use the expanded for loop of pgfplots \pgfplotsinvokeforeach{1,...,7}{\addplot[black] table {plot3/fnxspy#1.txt};}


-1

\documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{filecontents*}{data.csv} a,b,c 1,4,1 2,3,2 3,5,3 4,1,4 5,3,5 \end{filecontents*} \begin{document} \begin{tikzpicture} \begin{axis} [ axis lines=center,view={125}{30}, xlabel={$x_1$}, ylabel=$x_2$,zlabel=$z$, xtick={1, 2, 3, 4, 5},ymin=0,ymax=5, ...


1

Use \addplot3 to make a 3D-plot, and then set the either x or y to zero (depending on which plane you're in) with x expr=0/y expr=0 as in the code below. I also set axis lines=center and modified the view, to get something similar to your sketch. \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \usetikzlibrary{...


6

Set axis line style={draw=none} in the axis options. To remove the ticks as well, add tick style={draw=none} in addition. In older versions of pgfplots the draw=none approach for axis lines will not work, but one can set the opacity to zero instead: axis line style={draw opacity=0}, or possibly for x- and y-axis separately, y axis line style={draw opacity=0}...


3

I have edited a little bit on the code given by @Claudio. and I came up with this solution. \documentclass[10pt]{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \draw[->, thick](0,0)--node[below]{$Tails(x)$}(5,0) ; \draw[->, thick](0,0)--node[left]{$Heads(y)$}(0,5); \draw[- ] (4,0)node[below]{$(n,0)$}--(0,4) ...


1

Your comment is almost a solution. You might want to use axis lines=middle to match the sketch from your question. \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[axis lines=middle, xlabel=$\mathrm{Tails}(x)$, ylabel=$\mathrm{Heads}(y)$, domain=0:15,no marks] \addplot {-x + 10}; \...


8

Why not make use of pgfplots's cycle list feature which automatically chooses another line- and pointstyle, as well as another color for each line. \documentclass[a4paper]{abntex2} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{siunitx} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \begin{figure} \centering \begin{...


3

Some keys don't execute/expand their argument but parse them immediately. Imagine you had some fragile macros in your symbolic labels which would lead to errors if you have expanded them or some other scenario might lead to problems. Hence you have to provide the expanded version. For the second macro you have defined, if you actually force the macro to be ...


8

Here is one way that you can generalize for your own needs \documentclass{standalone} \usepackage{colortbl,pgfplotstable} \pgfplotstableread[header=false]{ 1 0 1 0 3 0 0 1 1 3 0 0 0 0 3 }\myB \pgfkeys{/mytable/.is family} \pgfkeyssetvalue{/mytable/0}{gray} \pgfkeyssetvalue{/mytable/1}{black} \pgfkeyssetvalue{/...


1

You've just forgotten the backslash in the final \x in the definition of your Distance function. And as mentioned in a comment, pgfmath already defines floor and ceil, so you don't have to define them yourself. \documentclass[border=5mm]{standalone} \usepackage{amsmath,amssymb} \usepackage{pgfplots} \tikzset{ declare function={Distance(\x)=min(\x-floor(\x),...


3

Remove the color=black option, and apply a style to each node via every node/.style=: Code: \documentclass[a3paper]{article} \usepackage{calc,graphicx,eso-pic,tikz,} \tikzset{My Node Style/.style={draw=pink, fill=pink, fill opacity=0.50, text opacity=1}} \begin{document} \begin{tikzpicture} \begin{scope}[local bounding box=scope1, every node/.style=...


1

the problem caused in \foreach, also look at \foreach not behaving in axis environment to solve the problem I use (during using colormaps) \edef\temp{\noexpand\addplot[color of colormap={\l}, solid, mark=none,domain=-1:1,samples=100]{\k*x};} \temp instead of \addplot[color of colormap={\l}, solid, mark=none,domain=-1:1,samples=100]{\k*x}; ...


4

You can for example use x post scale=-1 for the second axis. To remove any gap between them, set the location of the second axis to the south east anchor of the first one, and set its anchor to south west. x axis line style={-} added after axis lines/axis x line will remove the arrow head. To place an x-label in the middle, easiest is to add a \node after ...


4

Use \subcaption{\label{fig:a}} and \subcaption{\label{fig:b}} to set the subcaptions. Code: \documentclass{article} \usepackage{caption} \usepackage{subcaption} \usepackage{pgfplots} \pgfplotsset{compat=1.13}% <- added, current version is 1.13 \usepgfplotslibrary{groupplots} \begin{document} \begin{figure}[htb] \begin{tikzpicture} \begin{...


3

The argument is not expanded; you need to expand it before \begin{axis} absorbs the options: \documentclass{standalone} \usepackage{filecontents,catchfile} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.7} \usepackage{pgfplotstable} \begin{filecontents}{testcountries.txt} AUT,GER,FRA \end{filecontents} \begin{filecontents}{CountryYears.csv} ...


0

I just found a simple solution today while using their latest version of matlab2tikz. Run the code in LuaLaTeX instead of pdfLaTeX. This solves the issues of ! TeX capacity exceeded, sorry [main memory size=5000000] while running on Mac or TeX capacity exceeded, sorry [main memory size = 3000000] in case of Windows OS. But I found a new problem on the ...


1

It's possible to define where to place tick marks and the label for each mark: \documentclass{standalone} \usepackage{mathtools} \usepackage{pgfplots} \usepackage{siunitx} \sisetup{per-mode=symbol} \begin{document} \begin{tikzpicture} \begin{axis}[ xmin=0,xmax=20, ymin=0,ymax=20, axis y line*=left, axis x line*=bottom, ...


0

If you use rel axis cs:0,0 instead of axis cs:0,\pgfkeysvalueof{/pgfplots/ymin} this works fine. Note that without \pgfplotsset{compat=1.13} (any version number of 1.11 or higher is the same) you would have to add axis cs: before #1 in the macros. \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \newcommand{\...


0

An alternative to defining a piece-wise function is to define your function such that you can use it both for plotting and computing individual values, as given in the answer to this question: Consistently specify a Function and use it for computation and plotting Here's a MWE, where I've defined 2 functions A and B, plotted them over separate domains, and ...



Top 50 recent answers are included