gnuplot: use latex code in macros [duplicate] - latex

Using the following script in gnuplot (v 5.0) to generate a graph
set terminal epslatex
unset key
set xlabel "$\zeta$"
set ylabel "$\rho$"
set output "strange_graph.tex"
plot sin(x)
set terminal wxt
set o
along with a latex document to include it,
\documentclass{article}
\usepackage{amssymb}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\begin{center}
\include{strange_graph}
\end{center}
\end{figure}
\end{document}
the Greek letters rho and zeta do not appear on the axes, and furthermore r has disappeared from the y-axis, leaving "ho".
How do I fix this problem, and what is going on?
(And no, please don't ask me for an image, apparently I don't have enough reputation to upload one.)

You must either escape the backslashes, when using double quotes,
set xlabel "$\\zeta$"
set ylabel "$\\rho$"
or use single quotes
set xlabel '$\zeta$'
set ylabel '$\rho$'

Related

Tikz inside gnuplottex

Here is such a code.
\documentclass{standalone}
\usepackage[miktex]{gnuplottex}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{gnuplot}
set terminal epslatex color
set xrange [-4:4]
set yrange [0:16]
set xlabel '$x$'
set ylabel '$y$'
plot x**2 title '$y=x^2$'
\end{gnuplot}
\end{document}
Is it possible to draw primitives using tikz in a coordinate system created by gnuplot, similar to pgfplots? For example, \draw (axis cs:0 , 0) -- (axis cs:1 , 1);
There are probably many ways of doing so, here is a solution using the tikzlibrary tikzmark, which puts a custom mark called "a" in the ylabel string (but which could also be placed by an arbitrary set label command).
Your code was not compilable for me; one of the reasons is that the set terminal command has to be provided as an option to \begin{gnuplot} instead of inside the gnuplot code. Since you want to use tikz I would recommend to use the tikz terminal anyway.
\documentclass{standalone}
\usepackage{gnuplot-lua-tikz}
\usepackage{gnuplottex}
\usepackage[utf8]{inputenc}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{gnuplot}[terminal=tikz]
set xrange [-4:4]
set yrange [0:16]
set xlabel '$x$'
set ylabel '$\tikzmark{a}y$'
plot x**2 title '$y=x^2$'
\end{gnuplot}
An arrow going from the $y$ label to exactly here.\tikz[remember picture, overlay] \draw[<-, bend angle = 10, bend right] (0,0) to (pic cs:a);
\end{document}

How to ensure that the text paragraphs on the right side are consistent in the formula environment in the Latex?

I try to write the following formula in Latex
My question is that how to write the right-hand side formula? How to ensure that the text paragraphs on the right side are consistent in the formula environment?
My code is
$\mathbb{P}[\mbox{there exists a black path from ${0}\times [0,s]$ to $\pho s\mtis [0,s]$ in the rectangle $0,\pho s]\times [0,s]$}]
I suggest:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Text
\[
f_s(\rho)=\mathrm{P}%
\left[
\begin{array}{l}
\text{there exists a black path from }\{0\}\times [0,s]\text{ to}\\
\{\rho s\}\times [0,s]\text{ in the rectangle }[0,\rho s]\times [0,s]
\end{array}
\right].
\]
Text
\end{document}
giving this output:
Comment if this is ok with your code or not! :)

Using gnuplot, how to obtain a PDF with canvas size, including the texts?

Question
I want
neither
nor
Description
The first figure is what I want.
The second figure is obtained by
set terminal cairolatex pdf
set output 'cairolatex.pdf'
set xlabel '$\sigma$'
set ylabel '$\alpha$'
plot 'data' u 1:2 w l
For the third figure, first
set terminal cairolatex pdf
set output 'cairolatex.tex'
set xlabel '$\sigma$'
set ylabel '$\alpha$'
plot 'data' u 1:2 w l
Then
pdflatex plot.tex
where plot.tex is
\documentclass{article}
\usepackage{graphics}
\begin{document}
\input{plot.tex}
\end{document}
Edit:
Thanks to Ethan, I can reach
by
set term pdf size 10cm,7cm
set output 'term.pdf'
set xlabel '$\sigma$'
set ylabel '$\alpha$'
plot 'data' u 1:2 w l
But I want to use latex typesetting for xlabel and ylabel.
OK, revised answer to produce a figure using TeX typesetting. Several gnuplot terminals could do this but I recommend using tikz.
set term tikz standalone size 12cm, 7cm
set output 'figure.tex'
set xlabel '$\sigma$'
set ylabel '$\alpha$' offset -2
set xrange [1:7]
set lmargin 12
set border lw 2
plot 10.**x title '$10^x$'
unset output
!pdflatex figure

math in axes labels for gnuplot (epslatex terminal) not formatted correctly

Using the following script in gnuplot (v 5.0) to generate a graph
set terminal epslatex
unset key
set xlabel "$\zeta$"
set ylabel "$\rho$"
set output "strange_graph.tex"
plot sin(x)
set terminal wxt
set o
along with a latex document to include it,
\documentclass{article}
\usepackage{amssymb}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\begin{center}
\include{strange_graph}
\end{center}
\end{figure}
\end{document}
the Greek letters rho and zeta do not appear on the axes, and furthermore r has disappeared from the y-axis, leaving "ho".
How do I fix this problem, and what is going on?
(And no, please don't ask me for an image, apparently I don't have enough reputation to upload one.)
You must either escape the backslashes, when using double quotes,
set xlabel "$\\zeta$"
set ylabel "$\\rho$"
or use single quotes
set xlabel '$\zeta$'
set ylabel '$\rho$'

Problem with pgfplot label

I want to draw an x-y-diagram with axis labels. Unfortunately the ylabel is misplaced. It looks as depending on the actual data. When the other data line in the sample below is used instead of the upper line, it looks better.
How can I move the label to the left or (more desirable) how can I tell pgfplot to do it corectly?
% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=13cm,height=8cm,
xlabel={I in mA}, ylabel={U in mV}]
\addplot[only marks,mark=star] coordinates {
% (1.36, -0.0177) (45.38, 0.0273) (74.19, 0.0413)
(100.88, 0.0533) (134.80, 0.0683) (195.27, 0.1073)
};
\end{axis}
\end{tikzpicture}
\end{document}
pgfplots 1.3 has a new feature which allows to move axis labels tight to tick labels automatically. Since this affects the spacing, it is not enabled be default.
Use
\usepackage{pgfplots}
\pgfplotsset{compat=1.3}
in your preamble to benefit from the improved spacing.

Resources