Hot answers tagged

40

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 ...


24

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....


21

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 ...


19

(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 ...


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) ...


15

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 ...


15

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

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{...


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{...


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 ...


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

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

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 ...


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

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

I'd consider this a bug in gnuplottex.sty: the package tests shell escape by writing a file in /tmp and assigning it a name without extension. TeX implementations may differ in the treatment of missing extensions in file names, but should do the same thing when an extension is found. So if the test is %% test if shell escape really works \ifShellEscape \...


8

PGFPlots have both a layering system and a drawing order system. The option axis on top draws the axis lines and ticks over the graph area.


8

Out of the many( latex, tex, epslatex,pstricks pdf and lua/tikz) gnuplot terminal exports available epslatex seems reasonable. Using [terminal=epslatex,terminaloptions=color] seems to be optimal since .eps plot is taken from gnuplot and TeX is used to typeset text in labels/titles to give nice consistency. But for more options gnuplottex might give details. ...


8

I'm not fluent in gnuplot, so this could be refined. You can pass parameters based on \textwidth, as long as they are in the options to gnuplot: \documentclass{scrreprt} \usepackage{lipsum} \usepackage[cleanup]{gnuplottex} \usepackage{xparse} \ExplSyntaxOn \DeclareExpandableDocumentCommand{\convertlen}{ O{cm} m } { \dim_to_decimal_in_unit:nn { #2 } { 1 #...


8

Your data seems to be arranged in set of rectangular patches. So the key patch type=rectangle. Use opacity options to avoid (for the most part) the superposition problem (with axis) produced by current limitations of pgfplots. (For absolute control over the 3D object and lighs use Asymptote instead, in any case pgfplots will get you 99% there and it will be ...


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