Tag Info

38

Version 1.10 of pgfplots has been released just recently, and it comes with a new solution for the problem to fill the area between plots. Note that the old solution is still possible and still valid; this here is merely an update which might simplify the task. In order to keep the knowledge base of this site up-to-date, I present a solution based on the ...

23

EDIT Starting with pgfplots 1.14, you can draw filled contour plots by means of builtin methods in pgfplots: \documentclass{standalone} \usepackage{pgfplots} \usepgfplotslibrary{colorbrewer,patchplots} \pgfplotsset{compat=1.14} \begin{document} \begin{tikzpicture} \begin{axis}[ domain = 1:2, %y domain = 0:90, y domain = 74:87.9, view = {...

23

Using TikZ and pgfplots the best option is adding ycomb to your plot, as follows: \documentclass{article} \usepackage{tikz,pgfplots}%http://www.ctan.org/pkg/pgf http://www.ctan.org/pkg/pgfplots \begin{document} \pgfplotsset{ standard/.style={%Axis format configuration axis x line=middle, axis y line=middle, enlarge x limits=0....

20

(The answer is inspired by the jaytar's comment) You can use pythontex for that. Note that if your potential function is U(x) then the field lines are orthogonal to its level curves, so they are solutions of the differential equation dx/dt=DU(x) (or -DU(x), it doesn't matter). In the following code I use the scpiy.integrate.odeint function to solve the ...

19

To get LaTeX in labels or legends in Gnuplot, you need to use one of the terminals that produce LaTeX code. For example, you could use the latex terminal: set terminal latex set out 'plot.tex' plot [-5:5] [-1.5:1.5] sin(x+pi) title "$\\sin(x+\\pi)$" set out That will produce a plot.tex file that includes the plot using basic TeX statements. You can ...

18

The first function \documentclass[pstricks,border=12pt]{standalone} \usepackage{pst-plot,pst-node} \begin{document} \psset{xunit=.5} \begin{pspicture}(-1,-.5)(16.5,2) \psaxes[Dy=.5]{->}(0,0)(-.9,0)(16,1.5)[$n$,0][$l[n]$,90] \curvepnodes[plotpoints=16]{0}{15}{t 1}{A} \psset{linecolor=red} \multido{\i=0+1}{\numexpr\Anodecount+1}{\psline{-o}(...

17

Another possibility: filled contours with Asymptote, MWE: % fcontour.tex: \documentclass{article} \usepackage[inline]{asymptote} \usepackage{lmodern} \begin{document} \begin{figure} \begin{asy} import graph; import contour; import palette; defaultpen(fontsize(10pt)); size(14cm,8cm,IgnoreAspect); pair xyMin=(1,74); pair xyMax=(3,86); real f(real x, real y) ...

16

Asymptote contour3 package draws 3D surfaces described as the null space of real-valued functions of (x, y, z). Note that the images here are rendered into raster format (png). % impsurf.tex : % \documentclass[10pt,a4paper]{article} \usepackage{lmodern} \usepackage{subcaption} \usepackage[inline]{asymptote} \usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]...

15

While tikz can do basic graphs, you should use pgfplots for graphing: As hpesoj626 commented, sometimes it is better to have the axis lines in the middle. This also shows some of the other options that pgfplots provides: Code: \documentclass[border=2pt]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture}[scale=1.0] \begin{axis} \...

14

With PSTricks (If you don't mind to make a try): \documentclass[pstricks]{standalone} \usepackage{pst-func} \begin{document} \begin{pspicture}(-2,-2)(2,2) \psaxes{<->}(0,0)(-1.5,-1.5)(1.5,1.5)[$x$,0][$y$,90] \psplotImp[ linecolor=red, stepFactor=0.1, algebraic, ](-1.5,-1.5)(1.5,1.5){(x^2+y^2)^3-4*x^2*y^2} \end{pspicture} \end{...

14

Plotting heatmaps with gnuplot and LaTeX with small file size Basically, there are two different ways to draw heatmaps with gnuplot: Plotting with image Plotting with pm3d and splot Both have their advantages and disadvantages, and which one should use also depends on the actual data structure. The following terminals allow typesetting text with LaTeX and ...

14

You can use de the bodegraph package (https://www.ctan.org/pkg/bodegraph) http://www.texample.net/tikz/examples/bode-plot/ for your example first : the plot of the amplitude and phase diagrams \documentclass{article} \usepackage{tikz} \usepackage{bodegraph} \begin{document} \begin{tikzpicture}[xscale=15/4] \begin{scope}[yscale=3/50] \UnitedB \semilog{...

12

Here is what I did to get gnuplot working on a Mac. (You need to use the Terminal for this.) Goto GNU Plot on Sourceforge and download the source code. This should unzip in a folder gnuplot-4.6.0 in your Downloads folder. Open a Terminal window and issue the following commands: (hit the return key after each; the last three commands will produce quite a ...

12

This happens because there are no valid samples in the first half of your plot. gnuplot by default uses 100 samples, starting with the first number in the sampling range and dividing the range equally in linear space. That means that in your case, you have samples at 0, 41.4, 82.8, etc. The first sample evaluates to NaN because of the division by zero in ...

11

User defined constants: \const{HalfCanvas}{1.5}% half of canvas width or height \const{InitAngleD}{30}% initial angle \const{MainR}{1}% main radius \const{ChildR}{2}% child radius \documentclass{beamer} \usepackage{pstricks-add} \usepackage[nomessages]{fp} \def\const#1#2{% \expandafter\FPeval\csname#1\endcsname{round(#2:3)}% \...

11

For diagrams you will get the best results when using vector graphics. Both gnuplot and matplotlib can export to vector graphics; file formats for vector graphics are e.g. eps or pdf or svg (there are many more). As you are using pdfLaTeX, you should choose pdf as output format, because it will be easy to include in your document using the graphicx ...

10

Remarks The paths with the arrows inside needed some extra attention, but on this great site I found a way to do it, of course :-). For more see this post: TikZ: How to draw an arrow in the middle of the line? The picture in your post I recreated the picture in your post with TikZ. Implementation \documentclass[tikz]{standalone} \usetikzlibrary{...

10

You need to use set xtics rotate You can also set xtics rotate by <angle> Code #!/usr/bin/env gnuplot set terminal pngcairo set output 'test.png' set xtics rotate # crucial line plot [][1:3] '-' using 1:xtic(2) with line 2.02 economic 2.04 education 1.94 sports 2.01 culture 2.07 artandmusic 1.93 political 1.94 articles 1.83 press 1.86 novel1 ...

10

This happens because the lengths of the quiver arrows are taken into account when calculating the axis range. The arrow that starts at (-2,0) has a non-zero length, the tip lies slightly to the left, so the axis range is increased so the full arrow is visible. To limit the axis range to the function domain, set xmin=-2, xmax=2, ymin=-2, ymax=2. I would ...

10

When treating big vector data like this, I fear a lot the possibility of having (undetected) visual aliasing. Consider for example a sinusoidal signal with period 10 (arbitrary units), with a noise of period 0.11. #! /usr/bin/env python3 # import math import numpy as np import scipy as sp t1 = np.arange(0.0, 100.0, 1e-3) y1 = np.sin(2*math.pi*t1/10) + 0.2*...

9

There's the package gnuplottex that does exactly what you want. Here's an example document, say test.tex: \documentclass[a4paper]{article} \usepackage{graphicx,amssymb,ifthen,moreverb,gnuplottex} \pagestyle{empty} \begin{document} \begin{gnuplot}[terminal=pdf] set autoscale # scale axes automatically unset log ...

9

First of all: Instead of defining the functions 9 times for different parameter values, you can simply use \pgfplotsinvokeforeach{<list>}{ <code> } to loop over the values. That makes the code much more compact and maintainable. Then, you can either use the contour prepared key, which tells PGFPlots to assume you're plotting contours, making it ...

9

If you want to have different line styles for the different data columns, you have to use separate \addplot commands. Fortunately, you don't have to repeat the commands manually: instead, you can loop over the columns using \pgfplotsinvokeforeach: \documentclass{article} \usepackage{tikz,pgfplots, filecontents} \pgfplotsset{compat=newest} \begin{...

9

If you run gnuplot <basename>-gnuplottex-fig1.gnuplot, you'll see gnuplot's error message plot for [i=1:14] 'benchmarks/test.csv' u (\$0+1):i title ''.i.'00 kb' with linespoints ^ "texse-gnuplottex-fig1.gnuplot", line 16: invalid character \ gnuplot is stumbling over the \$. You don't need to escape the ...

9

I think the best way to achieve this is the following: Add a line TEXMFDISTRO = /usr/share/texmf to /usr/local/texlive/2015/texmf.cnf, creating it if it is not present. Copy the definition of TEXMF and TEXMFDBS from /usr/local/texlive/2015/texmf-dist/web2c/texmf.cnf to /usr/local/texlive/2015/texmf.cnf Add TEXMFDISTRO between TEXMFLOCAL and !!\$TEXMFDIST in ...

8

Here is a nice introduction I found to drawing Venn diagrams: http://users.ju.edu/hduong/math220/venn_diagrams.pdf I put it here, since this question is one of the first results google gives when looking for "how to draw Venn diagrams" (naturally), and also other places refer here, but I feel none of the answers give an introduction to drawing Venn ...

8

To use the epslatex terminal with the test command, you first need to specify where to write the output. You can do that by issuing set out "<filename>.tex, then test, and then set out to close the file. You'll then get a <filename>.tex and a <filename>.eps. By using \input{<filename>} in a LaTeX document, you'll get the following ...

8

You can simply include both your TikZ pictures into one by placing them inside nodes of yet another TikZ picture. As long as you don't seriously have to worry about compilation time it is OK to write something like the code below. It also helps with the arrows in between. \documentclass{article} \usepackage{tikz} \usepackage[graphics,tightpage,active]{...

8

To shift part of a picture one can use a {scope} and one of the shifting options: shift=<coordinate> (Argument has do be in braces {} when it contains a comma ,) xshift=<distance> yshift=<distance> In the following example I’ll use shift and a predefined coordinate (shift) (the name doesn’t matter) to have easy access to the shifting ...

Only top voted, non community-wiki answers of a minimum length are eligible