Tag Info

New answers tagged

2

I'll show you how to stack external files on top of one another in the manner you want, assuming you've got the ticks, axes labels and titles of the main square images in the external files. I used the file you linked in your comment for the bottom layer, and since there were no other ones (and the higher ones are different - no axes labels), I used some ...


2

Grid lines go from the bottom of the coordinate system to the top, which is why the grid line go across the 2. There are other ways of drawing these lines though. To get the coordinate of the intersection between the two plot lines, you can use the features of the intersections library from TikZ. This is loaded by the fillbetween library, so it is not ...


2

PSTricks can help to analyze the graph. Because in the given interval 0 <= x <= 1/2 the function f(x)=(-2*x^3+3*x^2-9*x+4)/3 is almost identical to the line g(x)=(-8*x+4)/3 passing (0,f(0)) and (1/2,f(1/2)) as shown in the following figure. \documentclass[pstricks,border=24pt]{standalone} \usepackage{pst-plot} \def\f{(-2*x^3+3*x^2-9*x+4)/3} ...


2

I would say you can't because your interval is too small. See how the plot looks in wolfram alpha using small axis limits. https://www.wolframalpha.com/input/?i=-2%2F3+x%5E+3+%2B+x%5E2-3x%2B4%2F3+on+interval+0+to+0.5 Image generated from wolframalpha


5

You can disable this behavior by the option scaled y ticks = false. % arara: pdflatex \documentclass[12pt]{standalone} \usepackage{tikz} \usetikzlibrary{patterns} \usepackage{pgfplots} \pgfplotsset{compat=1.10} \begin{document} \begin{tikzpicture} \begin{axis}[% ybar=1.2pt, % configures `bar shift' width=0.80*\textwidth, height=7cm, ...


6

You could give the xticks directly. The manual reveals that one can use the 1,3,...,19 writing style (as it is used in a foreach statement). A minimal example without data would be \documentclass{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{loglogaxis}[ log basis x = {2}, xtickten = {5,7,...,19}, ] ...


3

There is no way to plot a function which is prepared for math typesetting. You will need to replicate the function by means of something like \pgfmathdeclarefunction{S}{1}{\valueP * (\alphaH + \valueZ * \alphaW) / (\valueP*(\alphaH + \valueZ * \alphaW) + \betaH + \valueZ * \betaW)} with \def\alphaH{4} \def\alphaW{5} ... you can also declare a function ...


3

The first problem, the strange Y characters can be considered to be a defect in pgfplots. In fact, it is the result of "premature optimization": pgfplots uses this format internally to represent floating point numbers in a normalized form - and it does not convert it back to IEEE numbers. Thinking about it, I believe that it should produce correct numbers. ...


1

You can use \tikzifexternalizing{<code for true>}{<code for false>} to make something different during the externalization: \documentclass{scrreprt} \usepackage{everypage} \usepackage{wallpaper} \usepackage{gnuplottex} \usepackage{pgfplots} \usetikzlibrary{pgfplots.polar} \usepgfplotslibrary{external} \tikzexternalize \begin{document} ...


1

CW from the comments. To restore the boxed axis, you need only remove the axis x line=middle. I have used sample plots in my code here since I didn't have your plotted functions. Code \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.10} \begin{document} \begin{tikzpicture} \begin{axis} [ grid = both, %grid in the picture ...


3

Using pgfplots you can do something like this: \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=middle, domain=-1:7, yticklabels=\empty, xtick={-1,...,7}, xticklabels={-1,...,7}, samples=100 ] \addplot[no markers] {-0.1*x*(x-3)*(x-3)*(x-6)}; \end{axis} \end{tikzpicture} ...


2

I think I understand your problem with restrict y to domain now, with the default amount of samples no data is actually produced in that y-domain. The simplest solution is to manually specify a different x-domain for that function and/or increase the sampling frequency so the plot is visible also with a restricted y-domain. \documentclass{article} ...


4

percusse's answer is correct. What beats me is that pgfplots should have done that automatically as soon as it encounters a fill between plot. Consequently, there is a second answer: This is a bug and will be fixed in the next version of pgfplots (probably 1.11 once it is ready).


3

If you use \begin{tikzpicture}[trim axis left, trim axis right], the axis will be centered correctly.


3

This happens because axis y line=right overwrites the ylabel style. If you swap the options around (axis y line=right,ylabel style={font=\tiny}) you get the expected result.


1

If you look at the warnings that pgfplots throw at you, it detects that there are duplicate col names and tries to help you to give them alternative names by postfixing --index[<duplicate number>]. So that is expected. However you can truncate the name to be displayed in the legend entry. I used xstring in a lazy fashion to see whether the double ...


7

I'm probably not satisfying the question, but it's rather an easy task with more \addplot commands in use, we only need to split up the data and preserve one common point for two consecutive sets - it is (1400,7.9426) point in this example. This approach works with two (as in this example) or even more separations. %! *latex mal-tikz-graph.tex ...


12

If you add set layers option the axis environment, it sets a hierarchricrhchaheal(!?) order as the standard layer order, namely axis background, axis grid, axis ticks, axis lines, axis tick labels, main, axis descriptions, axis foreground. This simply switches the order of drawing order. Hence it is feature not a bug. Otherwise you can reorder the layers as ...


3

You want enlargelimits=false combined with scale only axis and height. pgfplots adds some whitespace around the plot by default, enlargelimits=false removes that. \documentclass{article} \usepackage[margin=0.5in]{geometry} \usepackage{tikz} \usepackage{pgfplots} \def\myimage#1#2{%% \begin{tikzpicture} \begin{axis}[ scale only axis, ...


3

@alfC's comment is correct: it is the "clickable" lib which results in this annoying and misleading message. There is nothing to save. The purpose of the clickable lib is to allow clicking into plots and access meta data for individual points (if available).


2

I hope someone can come up with an answer which sticks entirely with tikz or pgfplots directives. Here's a solution that lets me both clip the extra white space and set the box to the desired height. My approach is to use pgfplots ability to clip the extra white space via hide axis clip bounding box=upper bound Then I save the graph to a box (or, I ...


7

Here's a bit of a start on the image. I first save the graph of your data in a standalone file (named graph_01.tex): \documentclass{standalone} \usepackage{pgfplots} \pgfdeclarepatternformonly{north east lines med}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{7pt} {7pt}}{\pgfqpoint{6pt}{6pt}}% { \pgfsetlinewidth{0.4pt} \pgfpathmoveto{\pgfqpoint{0pt}{0pt}} ...


4

The restrict <x/y> to domain keys does not set the domain used for calculating y values, that is done by the domain key. The default value for domain is -5:5, meaning that functions are evaluated for -5 <= x <= 5. Here is a quote from pgfplots' manual about the restrict keys: These keys append x (or y or z) coordinate filters to restrict ...


3

every x tick style is admittedly a little confusing since it is meant to be a generic key to access extra ticks AND tick labels as if you are defining a new axis. I don't know if this is the official point of view but following can say more than I can summarize \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.10} ...


2

You have clip=false in the groupplot options, so this would happen. Make it clip=true. If you had any other paths (\draw, \node etc.) that went outside the axis limits, you could add clip mode=individual to enable clipping of plot lines but not other paths within the axis. That is not needed here however.


2

This an attempt. pgfplotstable is required. This solution use foreach loop to read the data. Note: Use of horizontal.dat input via filecontents will work too. Code \documentclass{article} \usepackage{pgfplots,filecontents} \usepackage{pgfplotstable} \pgfplotsset{compat=1.8} %\begin{filecontents}{horizontal.dat} %Name Self PR ST PA CO TO %RS 95.8 87.8 ...


8

You could use the intersections library to compute the location of the arrow tips: Notes: The \edef in the \foreach is explained at \foreach not behaving in axis environment. Code: \documentclass[12pt]{article} \usepackage{pgfplots} \usetikzlibrary{intersections} \usepackage{filecontents} \begin{filecontents*}{Test.dat} Y T500 0 40 0.001 ...


3

According to pages 470-471 of the pgfplots documentation: Keep in mind that inside of an axis environment, all loop constructions (including custom loops, \foreach and \pgfplotsforeachungrouped) need to be handled with care: loop arguments can only be used in places where they are immediately evaluated; but pgfplots postpones the evaluation of many ...


10

Here's a possible solution, adapted from Jake's answer here. The code is well-commented, but the basic idea is to modify the styling of a comb-type plot, which has the correct general form. We need to change the mark, and shift and rotate it so the mark is aligned to the correct portion of the curve. The sampling may be adjusted using the each nth ...


2

As cmhughes mentioned in his comment, adding the option area style to the axis environment gives the desired formatting for the legend. Draw the lines before adding the plots. The code: \documentclass{article} \usepackage{pgfplotstable} \begin{document} \begin{figure}[H] \centering \begin{tikzpicture} \pgfplotstableread{ x Order ...


2

You can use axis direction cs as in \path (axis direction cs:0,0) node [anchor=north west,yshift=-0.65cm,xshift=-0.7cm] {0} node [anchor=south east,xshift=-0.5cm,yshift=-0.7cm] {0};}] Code: \documentclass{article} \usepackage[x11names]{xcolor} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis} [grid = major, clip ...


5

You can combine pgfplots' nodes near coords feature with restrict y domain to to avoid the trial-and-error process of finding the last non-clipped point. By using restrict y domain to=-10:10 (the same values as ymin and ymax) pgfplots discards any points that are not within that interval. Therefore, the last point within the interval will always be pos=1 ...


6

This is bit manul and you have to do some trial and error experimentation, but it works. You can use [pos=<fraction>] like node[pos=0.54](endofplotsquare){} ; Code: \documentclass{article} \usepackage[x11names]{xcolor} \usepackage{tikz} \usepackage{pgfplots} \begin{document} \begin{tikzpicture}[domain=0.01:5] \begin{axis} [grid = major, clip = ...


4

Expanding on John's very nice answer, I've copied some definitions from Plot functions and their point of intersection. It is in turn based on Jake's previous code linked in that question. Here, one of the main issues is the sample number and number of intersection computations. If you consider the following example, I've commented out the node that ...


5

Originally posted on PGFPlots: How to draw a label at a zero of a function? There may be a better way than this, but I haven't found one yet. \documentclass[border=2pt]{standalone} \usepackage{pgfplots} \usetikzlibrary{intersections} \newlength{\len} \newlength{\plotwidth} \newcommand{\getvalue}[1]{\pgfkeysvalueof{/pgfplots/#1}} %output will be given by ...


10

You can use cycle list name=<list>. there are few pre-defined lists -- color (from top to bottom) exotic black white mark list mark list* linestyles linestyles* auto If you want you can create your own list like \pgfplotscreateplotcyclelist{mycolorlist}{% blue,every mark/.append style={fill=blue!80!black},mark=*\\% red,every mark/.append ...


7

No MWE no explanation :) \documentclass{standalone} \usepackage{pgfplotstable} \begin{document} \pgfplotstableread[col sep=comma]{ items,section_1,section_2,section_3,section_4 10,82,42,38,22 20,38,24,20,63 30,44,49,39,40 40,58,48,47,47 50,58,45,59,41 }\mytable \begin{tikzpicture} \begin{axis} \pgfplotsinvokeforeach{1,...,4}{ \addplot ...


5

forget plot. This key leaves the \addplot in question out of the legend. \documentclass[a4paper]{article} \usepackage{pgfplots} \usepgflibrary{shapes.geometric} \usetikzlibrary{patterns,arrows} \begin{document} \definecolor{plotrangecolor}{HTML}{D8D8D8} %{D8D8D8} %% %% ...


2

Just for typing exercise with PSTricks. \documentclass[pstricks,border=12pt,nomessages]{standalone} \usepackage{pst-eucl,pst-plot,fp} \psset{yunit=.5} \def\f(#1){((#1)^2-4*(#1)-7)} \begin{document} \begin{pspicture}[algebraic](-3,-12)(7.5,7.5) \psaxes[Dy=2,Dx=2]{->}(0,0)(-3,-12)(7,7)[$x$,0][$y$,90] ...


4

You can set clip mode=individual to clip only the plot lines. However, this also clips nodes added at the end of the plot like in your code, as it is part of the same path. As a workaround you could add an empty, named node at the end of the plot, and place a new node at this location. \documentclass{article} \usepackage{pgfplots} \begin{document} ...


10

If you use clip=false you turn off the clever trimming mechanism of pgfplots. By default, the domain is larger than -1:1 hence you get the extra drawing (I think it's -6:6 it's -5:5 by default). So you have to adjust the domain too. \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ axis x line = middle, axis ...


8

The reason is that everything outside the axis is clipped, and with thick lines at the edge of the edge, part of them is chopped off (similar to Node only partially rendered near edge of plot). You could add clip=false to turn off clipping, or extend the y axis a little bit, e.g. with enlarge y limits={rel=0.01}. \documentclass{article} ...


0

I have changed the same .txt file name above to ellipbmoment.txt. I've solved it by brute force by scaling both axis and hiding the last plot. Solution below. I have also added the .txt file. ellipbmoment.txt \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} ...


5

Here is a tikz solution. Using \DrawHorizontalPhaseLine{0,2,4}{-0.5, 4.7}{1, 2.5} and \DrawVerticalPhaseLine[$y$]{0,2,4}{-0.5, 4.7}{1, 2.5} yields: The parameters to \DrawHorizontalPhaseLine are: The optional axis label to be applied (defaults to no label). The axis tick labels The positions of the right arrows as a comma separated list. The ...


1

Here's a way around those issues you mention in the comment above: use the sagetex package which give you the power of the CAS Sage to run the calculations. The code's probably not going to make much sense to you but all you'd need to do is change the value of e. By using the implicit plot function from Sage we don't need so many samples. ...


13

Expanding on @Peter Grill 's solution, here is how to calculate the x coordinates. \documentclass[border=2pt]{standalone} \usepackage{pgfplots} \usetikzlibrary{intersections} \newlength{\len} \newlength{\plotwidth} \newcommand{\getvalue}[1]{\pgfkeysvalueof{/pgfplots/#1}} %output will be given by \pgfmathresult \newcommand{\xcoord}[1]% #1 = node name ...


14

Here is an example of how to automatically compute the zero of the function using the intersections library: Notes: I don't know how to extract the x value of the intersection. The solution from Extract x, y coordinate of an arbitrary point in TikZ can extract the coordinate, but that needs to be converted to an axis cs value. Code ...


3

This is an attempt where ylabel was changed to mathbf because I use minimum packages required. A1: Change the parameter of cs:xx in every axis y label/.style={at={(ticklabel* cs:1.2)} A2: Use axis x line=bottom, axis y line=left, Or instead of axis lines=middle, which assumes intersection will happen. To get xtick label 0 use what ...


11

If you set scale only axis, there's no minimum height: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=newest} \newcommand\quadratic{% \begin{tikzpicture} \begin{axis}[hide axis, scale only axis, height=2ex] \addplot[mark=none]{x^2}; \end{axis} \end{tikzpicture}} \begin{document} This image \quadratic{} is a quadratic. ...


9

You can use symbolic x coords={...} and xtick=data Code: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.10} \pagestyle{empty} \begin{document} \begin{tikzpicture} \begin{axis}[symbolic x coords={$a_1$,$a_2$,$a_i$,$a_r$},xtick=data,] \addplot+[ycomb] plot coordinates {($a_1$,3) ($a_2$,2) ($a_i$,4) ($a_r$,1)}; \end{axis} ...



Top 50 recent answers are included