Tikz inside gnuplottex - latex

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}

Related

circuitikz - move current labels closer to current arrow

how can I move the current label closer to the current arrow. I.e. I want to move the i_1 closer to the arrow.
MWE:
\documentclass{standalone}
\usepackage[european,cuteinductors,fetbodydiode,straightvoltages]{circuitikz}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}[scale=0.65, arrowmos]
\coordinate (zero) at (0,0);
\draw (zero) to[R,-*,R=$R_1$,i>_=$i_1$] ++(2.75,2);
\end{tikzpicture}
\end{figure}
\end{document}
I tried to put a \vspace in front of the label but it didn't work.
I propose two solutions here: the first one is using a fake label and then setting the label manually (with a lot of flexibility), or using the provided styling for labels. Details in comments; you need a quite recent circuitikz for using this solution (>=1.4.2).
\documentclass{standalone}
\usepackage[european,cuteinductors,fetbodydiode,straightvoltages]{circuitikz}
\begin{document}
\centering
\begin{tikzpicture}[scale=0.65, arrowmos]
\coordinate (zero) at (0,0);
% First option
% use a blank label for the current, and name the component
\draw (zero) to[R,-*,R=$R_1$,i>_=~,name=myI] ++(2.75,2);
% manually place the label where you like
% myIcurrent is the normal position where the blank label is set
\node[below=1mm, anchor=center, red] at (myIcurrent) {$i_1$};
% you can also use bipole current style to change inner sep;
\draw (2,0) to[bipole current style={inner sep=0pt}, R,-*,R=$R_1$,i>_=$i_1$] ++(2.75,2);
\end{tikzpicture}
\end{document}
See circuitikz manual, https://texdoc.org/serve/circuitikz/0#subsection.5.6 .

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

gnuplot: use latex code in macros [duplicate]

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$'

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