Tag Info

New answers tagged

3

You can use the execute at <begin/end> <certain events> keys for a more consistent output. Also instead of the max data point you can use axis description cs to get the whole axis length independent from where the data points are. \documentclass{standalone} \usepackage{pgfplots} \makeatletter \pgfplotsset{compat=1.11, my extras/.style={ ...


1

Use two nested \foreach loops. Since \k depends on \n you could probably reduce it to one loop. I'm not a mathematician but I think the TeX part is correct here. \documentclass[9pt]{article} \usepackage{tikz,pgfplots} \newcommand{\nMAX}{20} \newcommand{\kMAX}{19} \begin{document} \begin{tikzpicture}[scale=1.2, font=\tiny] \begin{axis}[ axis x ...


2

This is similar to Why does \ifnum not work inside of TikZ style definitions?, but the situation is different. When processing label={...}, PGF looks for =; a workaround is thus hiding it: every node near coord/.append style={ label={ [black!80, label distance=-1ex] \ifnum\coordindex<1 ...


2

Try clip mode=individual instead of clip=false:


1

You can center legend placing it at position 0.5 (without units) which represents the the mid point of each axis. You can also the legend anchor. \documentclass[tikz,border=2mm]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ width=0.8\textwidth, ybar, enlargelimits=0.15, ylabel={\#Pathes}, ...


1

I solved it by using groupplots and some manipulations. Code: \documentclass[]{standalone} \usepackage{pgfplots} \usepgfplotslibrary{groupplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{groupplot}[group style={group size= 1 by 2},height=5cm,width=6.4cm,xtick=\empty]%[ybar stacked,xtick=\empty,]%ytick=\empty] ...


2

You can use every node near coord/.style={green}. \documentclass{beamer} \usepackage{pgfplots} \begin{document} \begin{frame} \pgfplotsset{compat=1.9} \centering \begin{tikzpicture} \begin{axis}[ width=0.9\textwidth, height=0.9\textheight, ybar stacked, ymin=0, enlarge y limits={upper, ...


4

The commands \addlegendentry and \addlegendimage are your friends. You will have to label each plot you are using before the last one. % arara: pdflatex % arara: pdflatex \documentclass{standalone} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{helvet} \usepackage{sansmath} \usepackage{pgfplots} \pgfplotsset{compat=1.11} ...


5

You can add the option update limits=false to the \addplot options of the second plot.


1

For figures - try InkScape - you can save your figure in many formats (this can handle complex figures also). For simple figures try TpX a TeX based drawing programme. Still you can use TeXCad or LaTeX Draw. Choice is yours. For plotting data - R produces eps figures - which can be incorporated in your LaTeX documents. An excellent book on R and LaTeX ...


0

Use named nodes inside the axis environment und then draw the angle marks outside the axis. \documentclass[10pt]{amsart} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \usepackage{tkz-euclide} \usetkzobj{all} \begin{document} \begin{tikzpicture}[ dot/.style={circle,fill,inner sep=1.5pt,} ] \begin{axis}[width=6in,axis equal image,clip=false, axis ...


0

I would report that to the maintainers. Looks really strange. If you do not stack them, one gets the correct result. % arara: pdflatex \documentclass[tikz,border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} \begin{axis}[ybar,xtick=\empty,ytick=\empty,legend cell align=left, legend ...


1

One possibility; for this example I used the following simple file diffecorrenti.txt: 1 2 3 -3 4 5 6 7 and suppressed parts of the original code that were not relevant to the question and to the solution. For the first requirement, you can use the axis cs coordinate system to place a \node with some predefined style at the desired location at one ...


5

Use a box. \documentclass{article} \usepackage{pgfplots,tikz} \usepackage{caption} \DeclareCaptionLabelSeparator{fullstop}{.\quad} \captionsetup[figure]{labelsep=fullstop} \pgfplotsset{width=120mm} \newbox{\mybox} \savebox{\mybox}{% \begin{tikzpicture} \begin{axis}[ color=black, scale ...


4

The Plots with Standard Caption Something like this? I've included code to display the legend in one line but I've commented it because I'm not sure that is really what you mean. (It looks silly to me as the legend is then much wider than the plots! \documentclass{article} \usepackage{pgfplots,tikz} \pgfplotsset{compat=newest} \begin{document} ...


5

According to your log file, you have pgfplots 1.11 and pgf 2.10 . I can reproduce the problem in this combination. It works with both packages up to date (i.e. pgfplots 1.11 and pgf 3.00). It works with pgfplots 1.10 and pgf 2.10. Solutions alternatives for you are: upgrade PGF to 3.00 or downgrade pgfplots to 1.10 or use \addplot ... gnuplot {atan(x)}; ...


3

This is one possible solution with pgfplots. Here internal labels x\i and y\i are defined alone the blue line via coordinate[pos=xx] where 0 < xx < 1. Then vertical lines with relative distance are drawn from the points on the blue line. The distance is given via \h variable. Lastly, label the \epsilon_1 and y_i, \hat y. Code ...


3

To get the desired format you can apply: draw=red, pattern=north west lines, pattern color=red to provide the pattern for the fill of the bars marks=none to eliminate the dots /pgf/number format/fixed and /pgf/number format/precision=0 to control the display of the x ticks labels, and ylabel={Count} andxlabel={Time}` to label the axis Code: ...


0

Using clipping seems to be the right solution. Also see this question on using clipping. Your MWE would then become: \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \usepackage{savetrees} \begin{document} \begin{figure}[b] \centering \begin{tikzpicture} \clip (-0.5, -1) rectangle (15, 19) \begin{axis}[ ...


3

You need to put the macro involving entries inside a brace pair such as \addplot [fill, color=green,solid,forget plot, opacity=0.2] table[row sep=crcr]{ {\xmin+0} 1\\ {\Kone} 1\\ -1.826110508097425 0.6\\ {\xmin} 0.6\\ };


5

(OP here) After some work (and help from here!), I've come up with a graph that I hope others will find useful. Packages pgfplots and tikz are used, and tikz libraries positioning,calc, and plotmarks are used. Everything is calculated from a list of variables under %variable definitions. I wasn't able how to find out to redefine \t before each set of ...


7

You can fix the problem by disabling the decoration for the marks using mark options={decoration={name=none}}: \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \usetikzlibrary{decorations.text} \begin{document} \begin{tikzpicture} \begin{axis} \addplot+[ no markers, decoration={ text along path, ...


6

This is a proposed solution after investigating the OP's code. axis cs:x,y syntax should be used in pgfplots when tikz commands are used. The solution adds a scaling factor \s and set it to 0.2 for better presentations. Settng \s to 1 will be the OP's original value. For vector drawing, only two points are required, since the v_x and v_y can be drawn ...


4

The problem with \begin{tikzpicture}[scale=0.65] is that the fonts get scaled too making them look smaller. You can adjust the width of the plots instead with the option width provided by pgfplots. You can make this for all plots by adding \usepackage{pgfplots} %For creating plots inside LaTeX itself \pgfplotsset{width=2in} %%<-------------------- this ...


2

use for both \begin{tikzpicture}[scale=0.65] ...


1

I came up with the following solution, which requires the inclusion of an additional column in the original table. Such additional column must contain the widths I referred in my question. The code is divided in 3 distinct plots: marks for the original points; a const plot shifted (-) by half of the corresponding widths (black line); and a jump mark right ...


1

tikz can do this: \documentclass[tikz,border=5]{standalone} \begin{document} \begin{tikzpicture} \foreach \x in {0,...,5}{ \draw (\x,0.2) -- (\x,-0.2)node[below]{\x}; } \draw[fill=magenta!40] (3.5,0) circle (3pt)node[above=0.2cm,anchor=south]{3.5}; \node[anchor=north] at (0,-0.6) {Start}; \node[anchor=north] at (5,-0.6) {End}; ...


1

This PGFPlots example seems close enough to your plot (here is its PDF output). You can tweak it according to your needs; read the PGFPlots documentation to learn how.


0

Manual inclusion of currfile Simple addition of \usepackage{currfile} at the beginning of main and picture file, as described in currfile's manual does not solve my problem. I instead opted for manually adding \currfiledir whenever a relative path in some pics\ folder is needed. This retains the advantages of a standalone picture, which can also be ...


7

Put xtick={0,4,8,12,20}, in the first one. \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \definecolor{mycolor1}{rgb}{1,0,1} \definecolor{mycolor2}{rgb}{0,0.498039215803146,0} \begin{tikzpicture} % f1 \begin{axis}[ color=black, scale only axis, xmin=0.5, xmax=20.5, ...


6

This proposal uses animate in the beamer class, via tikz, to simulate projectile motions and one can see the vectors at any instant by clicking the > arrow at the bottom while triangle is for a continuous trajectory. The simulation uses g=2 instead of g=9.8 so that more points can be obtained. Update (2014/12/9) The OP needs the graph in article class ...


1

You need to put the column specifications into the table options. See below. Note that I have changed several things: The mathtools package loads the amsmath package, so loading both is not necessary The pgfplots package loads the tikz package, so loading both is not necessary circle is not a valid mark shape. The correct mark for a filled circle is * and ...


1

I am not sure of the intended result. Here is a plot of an ellipse. \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} \begin{axis}[width=12cm,height=6cm,trig format plots=rad,variable=t] \addplot[red,thick,domain=-2*pi:2*pi,samples=200] ({10*cos(t)},{sin(t)}); \draw (0,1) -- (0,-1) (-10,0) -- ...


0

I ended up faking it. \begin{tikzpicture} \begin{axis}[ width=\linewidth, height=0.6\linewidth, axis lines=left, ymin=0, ylabel={Price (NOK)}, ylabel near ticks, minor xtick=\empty, xtick={52, 104, ..., 260}, xticklabel=\empty, xmajorgrids=true, ] \addplot ...


1

Percusse's answer helped me a lot, but the colorbar was not placed perfectly aligned to my plot. I made a slight modification, which works without using an extra \node and without static widths. This is done by placing the colorbar with colorbar style. The colorbar is finally displayed by \pgfplotscolorbarfromname{commonbar}. \documentclass{standalone} ...


0

Okay, fair enough. I've had a go and also slightly expanded the problem... Here's an example code and corresponding image. The method for setting the colour for the two curves is something I pinched. The reason for doing it this way is that the data on the left is related to a combined surface and contour plot (not shown) with a colour scheme using the ...


2

This is a solution (where article cass is used here since revtex4 can not be installed currently). Two different lablel skills are applied. One (auto title, requiring alphalph package) uses \makeatletter \pgfplotsset{ auto title/.style={title=(\AlphAlph{\pgfplots@group@current@plot}) } } \makeatother The other (in red color) uses \node (A) at (group ...


2

This is one possibility. Here grid=both is added, ymin/ymax are set to differnt values and y tick label styes are added and set differently to meet the requirements. For legend in one row, use legend columns=-1. For two plots in one legend, use \addlegendimage{/pgfplots/refstyle=plot_one} addlegendentry{y axis 1} Code \documentclass{article} % UNITS ...


5

My approach relies on the idea to use draw=none for the decorated path. I chose to use two \addplot commands in an axis (as that simplifies my parametric plot), but that is essentially equivalent to a separate tikz path: decorations can be applied even if the main path has draw=none: \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots} ...


2

Version [2014/11/27] of animate extends option poster to also accept a zero-based frame number, not just first, last or none. Thus, to show the second frame of the animation as the default frame, i. e. sin(2x), as requested in the OP, put poster=1 to the option list. This frame is also shown in viewers which do not support JavaScript-based animations. OP's ...


2

Thanks to @percusse I switched to groupplots and then found this Q/A that helped me: Create x and y label which overlaps for multiple plots


4

You marked it as pgfplots but using TikZ syntax. Here is a pgfplots example \begin{tikzpicture} \begin{axis}[xlabel=$x$,ylabel=$y$,domain=1:3,no marks,axis lines=middle,enlargelimits] \foreach \a in {0,...,5} \addplot[purple] plot (x,{x^2 +1 + \a*(x-2)*(x-4)}); \end{axis} \end{tikzpicture}


6

Easy ad-hoc solution: (the command used is pretty self-explanatory: think of it as taking a rectangular selection in Photoshop and deleting everything outside of it) \begin{tikzpicture} \draw[->] (-1,0) -- (5,0) node[right] {$x$}; \draw[->] (0,-1) -- (0,8) node[left] {$y$}; \begin{scope} \clip (0,0) rectangle (5,8); \foreach \a in {0,...,5} ...


3

There is an odd character before \pgfplotsset: \pgfplotsset{tick label style={ In the posting it is the Unicode replacement character, but it could be something else in the source code (a candidate would be the unbreakable space character, sometimes inserted by editors). After removing it, the example would probably run fine. Otherwise check the ...


2

This is one way of doing it. Firstly, the proposal converts points into axis cs coordinate so that they are comparable with the pgfplot axis. The right angles on the triangle are found via intersections of grid lines notion, that is, finding intersection points of parallel lines that are parallel to lines A-Q and P-Q. Code ...


2

I've tried creating a class for each of the five data types (such that 1 -> [a]), and just writing the name of the color in place of the color integers. Did you do like this? scatter/classes={ 1={mark=*,mark options={},blue},% 2={mark=*,mark options={},red},% 3={mark=*,mark options={},color1},% color1 is defined as you did. 4={mark=*,mark ...


5

For applications like these, I would go with \addplot ... table instead of \addplot ... coordinates. That makes it easier to access coordinate attributes, and it also makes it much easier to use data from external applications in PGFPlots. If you provide the data as a table, you can use the discard if={<column name>}{<value>} and discard if not ...


2

You can use \addlegendimage{empty legend} \addlegendentry{1\textsuperscript{st} row :} to add a dummy legend at appropriate place: \documentclass{article} \usepackage[pdftex, active, floats, tightpage]{preview} \usepackage[utf8x]{inputenc} \usepackage[T1]{fontenc} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{figure} ...


4

There is nothing special about tikzpicture here you would see the same with {\centering X} \centering works by setting the paragraph parameters, so if you close the group before the paragraph ends then nothing happens. You can use {\centering X } To centre an X (or a tikzpicture). Or more naturally use \begin{center} X \end{center} which also ...


1

Something like this? \begin{tikzpicture} % Set horizontal range \pgfmathsetmacro{\nx}{8} % Set vertical range \pgfmathsetmacro{\ny}{2.5} \pgfmathsetmacro{\xmin}{2*(sqrt(\ny+1)-1)/\ny} \pgfmathsetmacro{\xmint}{2/sqrt(\ny)} \pgfmathsetmacro{\xminb}{4/\ny} \pgfmathsetmacro{\xmax}{2*\nx} \begin{axis}[xmin=0,xmax=\xmax,axis x line*=middle, axis y line*=left, ...



Top 50 recent answers are included