2

This question already has an answer here:

I get the error:

    ! Undefined control sequence.<recently read> \c@lor@to@ps }

when trying the following graph

\documentclass[11pt]{article}
\usepackage[usenames,dvipsnames]{pstricks}
\usepackage{epsfig}
\usepackage{pst-grad} % For gradients
\usepackage{pst-plot} % For axes
\usepackage{mathtext}

\begin{document}

\psscalebox{1.0 1.0} % Change this value to rescale the drawing.
{
\begin{pspicture}(0,-2.4101124)(5.36,2.4101124)
\psline[linecolor=black, linewidth=0.04, arrowsize=0.05291666666666667cm     2.0,arrowlength=1.4,arrowinset=0.0]{->}(0.8,-2.3398876)(0.8,2.4601123)
\psline[linecolor=black, linewidth=0.04, arrowsize=0.05291666666666667cm                 2.0,arrowlength=1.4,arrowinset=0.0]{->}(0.4,-1.9398876)(5.2,-1.9398876)
\psline[linecolor=red, linewidth=0.04](1.2,-1.5398877)(4.8,2.0601122)(4.8,2.0601122)
\rput[bl](0.0,2.0601122){\textcolor{red}{f(x)}}
\rput[bl](5.2,-2.3398876){\textcolor{red}{x}}
\end{pspicture}
}

\end{document}

It should be something easy, but I'm not a pro. Please, help me!

marked as duplicate by Christoph, jub0bs, user31729, Mico, Werner May 18 '14 at 21:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
% compile it with
% pdflatex -shell-escape filename

\documentclass[border=12pt,12pt]{standalone}% change it back to article or whatever you want to use
\usepackage{filecontents}
\begin{filecontents*}{diagram.tex}
\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-4,-1)(4.5,8.5)
    \psaxes(0,0)(-4,-1)(4,8)[$x$,0][$y$,90]
    \psplot[algebraic]{-2.5}{2.5}{x^2}
\end{pspicture}
\end{document}
\end{filecontents*}

\usepackage{pgffor,graphicx}
\foreach \compiler/\ext in {latex/tex,dvips/dvi,ps2pdf/ps}{\immediate\write18{\compiler\space diagram.\ext}}

\begin{document}
\includegraphics{diagram.pdf}
\end{document}

enter image description here

0

When using PSTricks, you have to use latex or xelatex to compile the image.

If you use TikZ/PGFPlots, you can also use pdflatex:

\documentclass[11pt]{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    axis lines=middle,
    xmin=0, xmax=10,
    ymin=0, ymax=10,
    enlargelimits,
    xtick=\empty, ytick=\empty,
    axis equal image,
    xlabel=$x$, ylabel=$f(x)$
]
\addplot [red, very thick, domain=1:10] {x};
\end{axis}
\end{tikzpicture}
\end{document}

Not the answer you're looking for? Browse other questions tagged or ask your own question.