Graphics, Figures & TablesGraphs with end arrows in PSTricks

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Graphs with end arrows in PSTricks

Post by coachbennett1981 »

Good afternoon,

I am new to PSTricks and am working with graphing functions. Specifically polynomials. I am wondering if I can make my graph have arrows at the end instead of just stopping. Here is the code I am using.

Code: Select all

\psPolynomial[coeff=2 -1 -1 .5 -.1 .025,linewidth=2pt,linecolor=red]{-1.5}{3} 
	\psaxes[linewidth=1.2pt]{<->}(0,0)(-4,-2)(5,3) 
	\psdot*[dotsize=5pt](2,-0.8) 
	\psdot*[dotsize=5pt](-0.4,2.2052) 
	\uput[r](2,-0.8){Relative minimum} 
	\uput[r](-0.2,2.2052){Relative maximum} 
		\vspace{.5in}
Any help would be appreciated. I have tried {<->} after psPolynomial, but that does not work, I get a failed message.

Nick

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Graphs with end arrows in PSTricks

Post by localghost »

coachbennett1981 wrote:Good afternoon, […]
Depends on the time zone. For me it's evening (09:30 PM).

Please provide a minimal working example (MWE). Nobody is willing to guess the pstricks related package where the \psPolynomial command comes from.


Best regards and welcome to the board
Thorsten¹
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Graphs with end arrows in PSTricks

Post by coachbennett1981 »

I will send you a copy of the file.. I think that is what you are asking. It is 4:30 and snowy here. I am in DC.

Code: Select all

\documentclass[12 pt]{exam}

%SET MARGINS
\setlength{\oddsidemargin}{-.45in}
%\setlength{\evensidemargin}{-.5in}
\setlength{\textwidth}{7.1in}
\setlength{\topmargin}{-0.95in}
\setlength{\textheight}{9.7in}
%UNCOMMENT NEXT LINE TO DOUBLE SPACE
%\renewcommand{\baselinestretch}{2}

%LOAD VARIOUS PACKAGES
\usepackage{graphics}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{multicol}
\usepackage{graphicx}
\input xy
\xyoption{all}
\usepackage{epstopdf}
\usepackage{pstricks}
\usepackage{pst-coil}
\usepackage{pst-node}
\usepackage{subfigure}
\usepackage{xkeyval}
\usepackage{pst-plot}
\usepackage{pst-poly}
\usepackage{pstricks-add}
\usepackage{pst-func}


\pagestyle{empty}

%MATH CHARACTER COMMANDS
\newcommand{\R}{\mathbb R} %REALS
\newcommand{\C}{\mathbb C} %COMPLEX
\newcommand{\Nat}{\mathbb N} %NATURAL NUMBERS
\newcommand{\Q}{\mathbb Q} %RATIONALS
\newcommand{\Z}{\mathbb Z} %INTEGERS
\newcommand{\lines}{\rule{\linewidth}{1pt}}
\newcommand{\be}{\begin{enumerate}}
\newcommand{\ee}{\end{enumerate}}
\newcommand{\beg}{\begin{aligned}}
\newcommand{\ea}{\end{aligned}}
%LOWER CASE V IN BOLDFACE
\newcommand{\vecv}{\mathbf v} 



\begin{document}

\begin{center}	
	\psPolynomial[coeff=2 -1 -1 .5 -.1 .025,linewidth=2pt,linecolor=red]{-1.5}{3} 
	\psaxes[linewidth=1.2pt]{<->}(0,0)(-4,-2)(5,3) 
	\psdot*[dotsize=5pt](2,-0.8) 
	\psdot*[dotsize=5pt](-0.4,2.2052) 
	\uput[r](2,-0.8){Relative minimum} 
	\uput[r](-0.2,2.2052){Relative maximum} 
		\vspace{.5in}
\end{center}


\end{document}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Graphs with end arrows in PSTricks

Post by localghost »

This is not a MWE. There are too many packages and declarations not related to the actual problem.

Somehow it makes no sense to me that the graph of a function shall end with arrows. The code below should work in theory, but it doesn't as expected. The arrows are still missing and there are no warnings or error messages.

Code: Select all

\listfiles
\documentclass{minimal}
\usepackage{pst-func,pstricks-add}

\begin{document}
  \begin{pspicture}[showgrid=false](-4,-2)(5,3)
    \psPolynomial[arrows=<->,coeff=2 -1 -1 .5 -.1 .025,linewidth=2pt,linecolor=red]{-1.5}{3}
    \psaxes[linewidth=1.2pt]{<->}(0,0)(-4,-2)(5,3)
    \psdot*[dotsize=5pt](2,-0.8)
    \psdot*[dotsize=5pt](-0.4,2.2052)
    \uput[dr](2,-0.8){Relative minimum}
    \uput[ul](-0.2,2.2052){Relative maximum}
  \end{pspicture}
\end{document}
According to the pstricks-add manual the specificaton of arrows like shown above is valid. I compiled on a MiKTeX 2.8 system with the most current versions of the involved packages. See list below.

Code: Select all

 *File List*
 minimal.cls    2001/05/25 Standard LaTeX minimal class
pst-func.sty    2008/03/21 package wrapper for pst-func.tex (hv)
pstricks.sty    2008/11/26 v0.40 LaTeX wrapper for `PSTricks' (RN,HV)
pstricks.tex    2009/11/27 v1.31 `PSTricks' (tvz,hv)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
   dvips.def    1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
pst-func.tex    2010/01/25 v0.66 `PST-func' (hv)
pst-xkey.tex    2005/11/25 v1.6 PSTricks specialization of xkeyval (HA)
 xkeyval.sty    2008/08/13 v2.6a package option processing (HA)
 xkeyval.tex    2008/08/13 v2.6a key=value parser (HA)
pstricks-add.sty    2009/03/17 v. 0.13 package wrapper for pstricks-add.tex (hv
)
pstricks-add.tex    2010/01/25 v0.66 `PSTricks-add' (hv)
  pst-fp.tex    2010/01/25 v0.66 `PST-fp' (hv)
 ***********
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Graphs with end arrows in PSTricks

Post by coachbennett1981 »

The graph works when I run it in TexShop. I have all the packages and things because I am teacher and like to have a general template of packages, etc. that I use. When you run the graph for a given domain, the graph does stop, but I would like arrows to appear at both ends of the graph {<->) for the graph. When I run the code with this {<->} write at the beginning of \psPolynomial{<->}.


Thanks for looking at this, I will look up Minimal working document..

Nick
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Graphs with end arrows in PSTricks

Post by localghost »

coachbennett1981 wrote:The graph works when I run it in TexShop. [...] When you run the graph for a given domain, the graph does stop, but I would like arrows to appear at both ends of the graph {<->) for the graph. [...]
It's absolutely clear to me what you want but it seems not possible to have graphs with arrows at the end. This still doesn't make sense to me because the graph of a function has not the character of a vector. Perhaps you should adjust the domain to show that the graph leaves this part of the coordinate system thus is continued outside.

Code: Select all

\listfiles
\documentclass{minimal}
\usepackage{pst-func,pstricks-add}

\begin{document}
  \begin{pspicture}[showgrid=false](-4,-2)(5,3)
    \psPolynomial[coeff=2 -1 -1 .5 -.1 .025,linewidth=2pt,linecolor=red]{-1.61}{3.22}
    \psaxes[linewidth=1.2pt]{->}(0,0)(-4,-2)(5,3)
    \psdot*[dotsize=5pt](2,-0.8)
    \psdot*[dotsize=5pt](-0.4,2.2052)
    \uput[dr](2,-0.8){Relative minimum}
    \uput[ul](-0.2,2.2052){Relative maximum}
  \end{pspicture}
\end{document}
There is always the possibility to use the pspicture* environment to cut everything that goes beyond the specified coordinates. That's all I can advice at the moment.
coachbennett1981 wrote:[...] When I run the code with this {<->} write at the beginning of \psPolynomial{<->}. [...]
This sentence is very confusing.
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

Graphs with end arrows in PSTricks

Post by CrazyHorse »

That was a bug in pst-func.tex
You can try it with this version:

http://voss.homedns.org/packages/pst-func/

Then a

Code: Select all

\psPolynomial[
  coeff=2 -1 -1 .5 -.1 .025,
  linewidth=2pt,
  linecolor=red,
  arrows=<->,
  arrowscale=2
]{-1.61}{3.22}
should work.

Herbert
Post Reply