Tag Info

New answers tagged

2

Run with xelatex(takes some time) or latex->dvips->ps2pdf: \documentclass{article} \usepackage{pst-electricfield} \begin{document} \begin{pspicture*}(-6,-6)(6,6) \psframe*[linecolor=lightgray!50](-6,-6)(6,6) \psgrid[subgriddiv=0,gridcolor=gray,griddots=10] \psElectricfield[Q={[-1 -2 2][1 2 2][-1 2 -2][1 -2 -2]},linecolor=red] \psEquipotential[Q={[-1 -2 ...


6

I don't see the need for boxes here, you can simply use: \documentclass{article} \usepackage{tikz} \newcommand\drawline[1][black]{% \begin{tikzpicture} \draw[#1] (0pt,0pt) -- (15pt,0pt); ...


3

Put the tikz in a box, and deploy the box in the caption. Note that by using a temporary box as in the first MWE below, it will not play well with a \listoffigures, but that can be circumvented by using a permanent box deployed prior to the \listoffigures. \documentclass{article} \usepackage{tikz} ...


4

I don't know if it has to be this difficult but here it goes. But seriously this plot is anything but beautiful. \documentclass[a4paper, 10pt]{article} \usepackage{pgfplots} \pgfplotsset{my error bars/.style={ /pgfplots/error bars/draw error bar/.code 2 args={% \pgfkeysgetvalue{/pgfplots/error bars/error mark}{\pgfplotserrorbarsmark}% ...


3

This should get you started. The code is raw and not coloured, these are left as assignment if you like. (I gotta run now sorry) \documentclass[border=5]{standalone} \usepackage{pgfplots} \pgfplotsset{width=7cm,compat=1.11} \pgfdeclareplotmark{mymark}{% \node[draw,circle,inner sep=0.5ex] (a) {}; \node[inner sep=0.5ex,above=2ex] (b) {}; \draw (b.north west) ...


1

The easiest way is xticklabel style={/pgf/number format/.cd,frac,frac TeX=\ds\frac,frac denom=2}, yticklabel style={/pgf/number format/.cd,frac,frac TeX=\ds\frac,frac denom=4}, for x ticks with denominator 2 and y ticks with denominator 4. frac TeX accepts the macro to use for typesetting the fraction—I've added your \ds directive here. This method is ...


4

It is easy using y index with pgfplots. \documentclass{article} \usepackage{pgfplotstable} \pgfplotstableread{ x y1 y2 y3 y4 0 3 4 13 14 1 5 6 15 16 2 2 3 12 13 3 4 8 14 18 4 6 9 26 19 5 8 1 18 11 6 10 2 12 12 }\mytable \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} ...


3

A tick label can contain anything that's allowed inside a Tikz node, with the caveat that if it contains comma(s), it must be protected with curly braces. Use xticklabels={\begin{tabular}{r}1\\2\\3\end{tabular},B,C}, in the axis options. The ,B,C is required because if one tick label text is manually specified, all of them need to be manually specified. ...


1

Smoothly interpolated color maps are supported for plot types mesh, surf, and patch. These, however, require either a mesh (=matrix) of data points on input or a sequence of patches. I suppose a sequence of triangular patches would do the job in your case. You would need to determine this triangulation on your own; pgfplots cannot do it based on your input ...


3

You should pass only marks to the \addplot not to the axis. \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.10} \begin{document} \begin{tikzpicture} \begin{axis}[] \addplot[black,only marks] coordinates {(0,0) (1,1) (2,2)}; \end{axis} \end{tikzpicture} \end{document}


4

When you use \addplot [...] function {...} it uses gnuplot on the terminal, which uses radians for trigonometric functions, as noted in Section 4.3.5 of the pgfplots manual. To use the pgf computation engine, remove the word function (or replace it with expression): \documentclass{standalone} \usepackage{pgfplots,siunitx} \pgfplotsset{compat=1.11} ...


2

Since you did not provide an MWE, I'm making a guess about the format of your .data file: Yellow 0 Green 1 Blue 2 Violet 3 U.V. 3 I create this using the filecontents package at the top of my example code. I used the filename lab3-paul.data so that it doesn't overwrite your real data file. :-) The main issue here is that pgfplots needs some ...


3

You can plot those circles like \begin{axis}[ axis y line*={right}, axis x line={none}, ymin={1}, ymax={5}, width={8cm}, height={5cm}, ylabel style={xshift=0.60em}, ylabel={units}, ] \addplot[only marks,mark=*,mark size=3pt,green, nodes near coords = \rotatebox{90}{{\pgfmathprintnumber[fixed zerofill, ...


1

You can control the postion of legend by at key as in legend style={at={(0.5,1)},anchor=north,draw=none,nodes={inner sep=3pt}}, %% changed here Adjust values in (0.5,1) as you wish. You are missing the comma , as the separator in xticklabels = { \strut Read 0, %% you need comma (,) at the end here and next 2 lines \strut ...


4

The legend image code for ybar legend is defined as (page 212 chapter 4) \pgfplotsset{ /pgfplots/ybar legend/.style={ /pgfplots/legend image code/.code={% \draw[##1,/tikz/.cd,bar width=3pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(0cm,0.8em) (2*\pgfplotbarwidth,0.6em)};}, }, It is nothing but a bar plot with two coordinates, so you get two bars. By ...


2

I'd recommend a combination of tools: Inkscape svg2tikz Once you install Inkscape, you can put svg2tikz in your ./config/inkscape/extensions directory and restart the program to get this functionality. Now, you just need to convert the bitmap to a vector. Inkscape has this functionality built-in (version 0.48). Step-by-step instructions: Import ...


13

I believe this is a bug in tikzlibrarypgfplots.units.code.tex. Take a look at lines 109-180, where the prefixes are defined. You'll find (for micro only): /pgfplots/x SI prefix/micro/.style={/pgfplots/axis base prefix={axis x base 6 prefix \mu}},% /pgfplots/y SI prefix/micro/.style={/pgfplots/axis base prefix={axis y base 6 prefix \mu}},% /pgfplots/z SI ...


3

Both of them should be inside the same tikzpicture environment. \documentclass[12pt]{standalone} \usepackage[x11names]{xcolor} \usepackage{tikz} \usepackage{pgfplots,pgfplotstable} \usepgfplotslibrary{polar} \pgfplotstableread{ t u 0 1 20 2 40 3 60 4 100 5 130 4 160 3 180 2 220 2 240 3 260 3 290 3 300 1 320 1 360 1 360 10 360 1 }{\data} ...


3

This is a weakness of pgfplots up to and including version 1.11 . The version 1.12 (which will be released within the next weeks at the time of this writing) will result in \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} \begin{axis} [ymax=11] \addplot+ [no marks] coordinates {(0,0) (1,0) ...


3

With all that siunitx settings, you can use nodes near coords={$\num{\pgfplotspointmeta}$}, Code: \documentclass{standalone} \usepackage{pgfplots,pgfplotstable} \usepgfplotslibrary{units} \usepackage{siunitx} \sisetup{ %strict, output-decimal-marker={,}, exponent-product=\cdot, detect-all } \pgfplotsset{compat=1.11} ...


3

Your problem is that you've listed point meta=explicit symbolic, which means pgfplots treats the point meta like a string and doesn't use \pgfmathprintnumber for printing. You can instead use the option point meta=explicit (not explicit symbolic) with the /pgf/number format/use comma to get what you want. Note that you need to specify explicit because ...


3

I made for my self a histogram this way: \documentclass[11pt,a4paper]{article} \usepackage{geometry} \geometry{margin=1in} \usepackage{tikz} \usepackage{tkz-euclide} \usetikzlibrary{calc,intersections,through,backgrounds,snakes} \usepackage{pgfplots} \pgfplotsset{compat=1.8} \usepgfplotslibrary{statistics} \usepackage{bchart} \begin{center} ...


0

I had a similar Problem using \begin{document} \pgfplotstableset{create on use ... } \pgfplotstablenew[create on use ...]{} \begin{tikzpicture} A blank space was created before the picture was drawn. I put the commands behind the \begin{tikzpicture}, which solved the problem. \begin{document} \begin{tikzpicture} \pgfplotstableset{create on use ...


6

Your first question can be answered by a number of posts on this site, e.g., number format in pgfplots axis. The simple solution is to add code for number formatting to your axis labels: /pgf/number format/1000 sep={} Your second question can be resolved by setting ymin=0 (or really, any ymin value, 0 happens to be a good choice IMHO). I would note that ...


3

You can do \ifnum\myLegend>0 \addlegendentry{red line}; \fi so nothing will be done when you have \newcommand{\myLegend}{0} while the legend will be seen if you have \newcommand{\myLegend}{1} Another approach is to have \newif\ifmyLegend in the preamble and \ifmyLegend \addlegendentry{red line}; \fi in the body of the tikzpicture. You ...


4

Use \addplot[color=blue, very thick, samples=80, domain=0:410] {0.357355263*x + 97} node[above] {{\scriptsize $V_1$}}; instead of \draw[color=blue, very thick, samples=80, domain=0:410] plot (\x,0.357355263*\x + 97) node[above] {{\scriptsize $V_1$}}; since you are using pgfplots anyway. \documentclass{beamer} ...


3

I believe there are two issues here: the first is an explanation for the red dot as it appears in the MWE and the second is to ensure that axis equal maps the 3D origin to TikZ's 2D origin. What sounds like just one issue turns out to be two separate ones: if you move the \fill[red,...] instruction outside of the axis (but inside of the tikzpicture), both ...


2

It is because you have set a smaller domain, If you use domain=-3.5:3.5 instead you get this: \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} \begin{axis} \addplot3[ surf, opacity=0.8, samples=50, samples y=30, %colormap/whitered, domain=-3.5:3.5,domain y=-1:1 %z buffer=sort, ] ...


3

This is very easy with \pgfplotsset{legend image post style={black},legend style = {text=black,font=\footnotesize}} You may also put this in axis options so as not to affect other places. \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture}[scale=0.68] \tikzset{every mark/.append ...


0

It's incredibly dirty, but I was able to use pretty much the same methodology you used for the axis colors for the legend: \documentclass{standalone} \usepackage{color} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture}[scale=0.68] \tikzset{every mark/.append style={scale=0.5}} \pgfplotsset{legend ...


3

The first step of debugging externalized tikzpictures is to make sure they work without externalization. Your example shows several errors when I comment out all externalization-related code: the end of every \draw, \node, \path, etc. needs a semi-colon and the first \draw line had a typo, the node name is in1 not inl. Also, I updated your code to use ...


2

I did the answer with the link controlling pgfplots axis labels (thank you Pier for the link) : I post the corrected ECM for the forum : \documentclass[10pt]{article} \usepackage{pgfplots} \usepackage{subcaption} \pgfplotsset{compat=1.10} ...


2

One note: don't use the center environment inside the figure environment: it adds extra unneeded vertical space. Just one \centering placed somewhere inside the figure environment will do the job better. Since I didn't have your data, I made some "dummy" functions that have roughly the same behavior. You can do the same for future questions: it makes it ...


1

An expl3-based answer, because that's what I was working on. I'm not too familiar with PGF :) \documentclass[a4paper,12pt]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \usepackage{filecontents} \begin{filecontents*}{data.txt} 1 1 2 2 3 3 4 4 5 5 \end{filecontents*} \usepackage{expl3} \ExplSyntaxOn \cs_new_nopar:Npn \NaturalLog #1 { ...


3

You want y expr=ln(\thisrowno{1}) (note parentheses and no backslash with ln). The parentheses are standard usage for the pgf math functions (e.g. sin(x), cos(x)). Inside key-value expressions, curly braces are only used to protect certain contents and to delimit macro arguments. By the same token \ln, \sin, \cos, etc. are used (in math mode) when we want ...


3

Note that axis lines=center installs the following style /pgfplots/every non boxed x axis/.style={% xtick align=center, enlarge x limits=false, x axis line style={-stealth} }, So the order of the options is crucial. You have to change the axis lines firstly and the inner axis line style (or axis line style) secondly. Additionally, the arrow tip is ...


3

You can use axis line style={-Latex[round]} or (x axis line style, for example). The code: \documentclass{article} \usepackage{pgfplots} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} \begin{axis}[inner axis line style={very thick,red}, axis lines=center,axis line style={-Latex[round]}] \addplot ...


0

This time with the mfpic package, which is a (La)TeX interface to MetaPost or Metafont (here used MetaPost). Note that this program is shorter than my correponding MetaPost coding, since mfpic already has its own drawing macros. In exchange it requires several compilations, à la bibTeX: first compile your LaTeX file, say grid.tex, with LaTeX, then the ...


3

A stack was too much to resist, so onto the bandwagon I jump. \documentclass{article} \usepackage[usestackEOL]{stackengine} \usepackage{xcolor,graphicx,amssymb} \setstackgap{L}{1cm} \def\stacktype{L} % DASHED LINE OF SPECIFIED LENGTH % From morsburg at http://tex.stackexchange.com/questions/12537/ % how-can-i-make-a-horizontal-dashed-line/12553#12553 ...


2

My own try with MetaPost, which is integrated into a LuaLaTeX program. I've picked up some macros I had already created for my own use (and modified some of them slightly). \documentclass[12pt]{scrartcl} \usepackage{unicode-math} \usepackage{luamplib} \everymplib{verbatimtex \leavevmode etex; def hgrid(expr ymin, ymax, ystep, u, v)(text mycolor) = ...


4

No graphics question is complete without a picture mode solution: \documentclass[border=2pt]{standalone} \usepackage{xcolor} \unitlength=1cm \begin{document} \begin{picture}(10.5,10.5)(-5,-5) {\color{gray} \thinlines \multiput(-5,-4)(0,1){9}{\line(1,0){10}} \multiput(-4,-5)(1,0){9}{\line(0,1){10}} } \thicklines \put(-5,0){\vector(1,0){10.2}} ...


14

Why pgfplots is left out? \documentclass[border=2mm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} \begin{axis}[grid=both,ymin=-5,ymax=5,xmax=5,xmin=-5,xticklabel=\empty,yticklabel=\empty, minor tick num=1,axis lines = middle,xlabel=$x$,ylabel=$y$,label style = ...


8

And here is a fairly generic Metapost approach to making a grid. prologues := 3; outputtemplate := "%j%c.eps"; beginfig(1); u = 1cm; ymax = xmax = 4.75; xmin = ymin = -4.75; path xx, yy; xx = ((xmin,0) -- (xmax,0)) scaled u; yy = ((0,ymin) -- (0,ymax)) scaled u; drawoptions(dashed evenly scaled .5 withcolor .7 white); for i = ceiling ymin upto floor ...


1

You can use the spacing commands \hspace and \vspace to get your desired spacing. You can see where I've added them in the code below. Note that I minimized your preamble for this example slightly, and in particular, pgfplots already loads tikz, so loading tikz separately is not necessary. \documentclass[paper=a4, fontsize=12pt, open=any, ...


8

with TiKZ: \documentclass[tikz,border=2mm]{standalone} \begin{document} \begin{tikzpicture} \draw[help lines, color=gray!30, dashed] (-4.9,-4.9) grid (4.9,4.9); \draw[->,ultra thick] (-5,0)--(5,0) node[right]{$x$}; \draw[->,ultra thick] (0,-5)--(0,5) node[above]{$y$}; \end{tikzpicture} \end{document}


3

A PSTricks solution: \documentclass{article} \usepackage{pst-plot} \begin{document} % parameter \def\size{5} \begin{pspicture}(-\size,-\size)(\size.57,\size.62)% found manually \multido{\iA = -\size+1}{\numexpr2*\size+1}{% \multido{\iB = -\size+1}{\numexpr2*\size+1}{% \psset{linewidth = 0.5\pslinewidth, linestyle = dashed, linecolor = gray!50} ...


2

pgfplots has several possibilities for plotting error bars. Each of them, along with the associated styling keys, is described in Section 4.12 of the pgfplots manual. Here I illustrate relative errors, explicit errors, and fixed errors: \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.11} \begin{document} \begin{tikzpicture} ...


2

CW from the comments: Using \addplot+ means that style options are appended to the default style (a cycle list). So the color specified by the default cycle list is overwritten by blue but other options (namely line style/dashing) are not. Correct the problem by simply using \addplot instead (unless you really do want to append only selected options, in ...


2

As shown in http://tex.stackexchange.com/a/208681/32374, you need to change how you specify the enlargement of the axes. Instead of enlargelimits=0.15, use enlarge x limits=.15, enlarge y limits={0.15, upper}, Then, I had to specify also ymin=0. I also edited your axes to use the ybar style instead of the plots, since this sets up the tick marks and such ...


8

you can use ybar=... to shift the bars apart. \documentclass{article} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ ybar=.5cm, ymin=50, ymax=120, height=5cm, width=7cm, xticklabels={enTwitter, +enNewswire}, ylabel=Accuracies (test set), ...



Top 50 recent answers are included