3

Normal View

alt text


Zoomed-In View

alt text


"Minimal" Code Snippet

\documentclass[11pt,rgb]{article}
\usepackage{pst-func}
\renewcommand\pshlabel[1]{{\color{gray}\tiny#1}}
\renewcommand\psvlabel[1]{{\color{gray}\tiny#1}}
\usepackage{graphicx}
\usepackage{bera}
\begin{document}
\noindent\scalebox{2}{%
\begin{pspicture*}[showgrid=false](-3,-3)(3,3)
  \psframe[fillcolor=black,fillstyle=solid](-3,-3)(3,3)  
  \psaxes
  [%
   linecolor=gray,
   tickcolor=gray,
   linewidth=0.25pt,
   xlabelPos=top,
   xticksize=-0.05 0.05,
   yticksize=-0.05 0.05%
  ]{<->}(0,0)(-2,-1.75)(2,2)[$\color{gray}x$,0][$\color{gray}y$,90]
  \rput[br](-1.75,1.5){\Large\bf\color{cyan}We}
  \rput(1.75,-1){\Large\bf\color{white}PSTricks}
  \psplotImp[linecolor=red,linewidth=0.5pt](-2.5,-1.75)(2.5,2.5)%
  {x 2 exp 1.25 y mul x abs sqrt sub 2 exp add 2.5 sub}   
  \rput(0,-2.25){\color{yellow}$x^2 + \left(\frac{5y}{4}-\sqrt{|x|}\right)^2=\frac{5}{2}$}
\end{pspicture*}}
\end{document}  

I noticed the produced curve is NOT symmetric about y-axis. It has to be symmetric about y-axis actually.

Display Name
  • 46,933

3 Answers3

6

that was not a minimal example ...

\documentclass{article}
\usepackage{pst-func}
\begin{document}

\noindent\psscalebox{2}{%
\begin{pspicture*}(-3,-3)(3,3)
  \psaxes[
   linecolor=gray,
   tickcolor=gray,
   linewidth=0.25pt,
   xlabelPos=top,
   labelFontSize=\scriptscriptstyle,
   labelsep=2pt,
   ticksize=-0.05 0.05
  ]{<->}(0,0)(-2,-1.75)(2,2)[$\color{gray}x$,0][$\color{gray}y$,90]
  \psplotImp[linecolor=red,linewidth=0.5pt,stepFactor=0.2,
     algebraic](-2.5,-1.75)(2.5,2.5){x^2+(5*y/4-sqrt(abs(x)))^2-2.5}
\end{pspicture*}}

\end{document}
  • @Herbert, thanks for informing stepFactor. I set it to 0.1 and the curve looks more smooth. – Display Name Dec 31 '10 at 07:33
  • @Herbert, can we fill in the region enclosed by the curve with a solid color? – Display Name Dec 31 '10 at 08:12
  • no, not possible, it is not a closed path of coordinates –  Dec 31 '10 at 08:56
  • @Herbert, why does the implicit curve plotting macro use dots rather than infinitesimal line segments? – Display Name Dec 31 '10 at 09:04
  • feel free to modify the macro, if you know how this can be realized ... However, it is a simple cardiode curve, no need for using an implizit defined function. –  Dec 31 '10 at 09:10
  • @Herbert, thanks. After grasping plain TeX and PostScript language, I will try to see the macros someday. :-) – Display Name Dec 31 '10 at 09:27
  • 1
    it is not a question of TeX or PostScript, it is a question of how an implizit defined function can be solved as a continuos series of points ... –  Dec 31 '10 at 09:33
  • Having fiddled with this myself (see http://tex.stackexchange.com/questions/4745/how-to-use-the-results-of-raw-output-to-create-a-smooth-plot) I can tell you it is not possible with gnuplot's output: you get coordinates of intersections of a surface and a plane: no continuity in the data. I fooled pgfplots into thinking it was continuous because gnuplot puts adjacent coordinates close to each other, but this is a heuristic. You could use my method for a smoother plot though, hoping it performs as good as my algebraic curves. I don't know how \psplotImpl works, but I guess analogously. – Pieter Dec 31 '10 at 09:51
  • (second part of the comment) But as @Herbert already showed, sometimes you don't need implicit plots. Hence, not the downsides that come with their (only?) implementation. – Pieter Dec 31 '10 at 09:52
  • 2
    @Pieter: it is possible, but you have to take all points of the curve and sort them in a way that it will be a continous curve. On PS side it is easy to save all found points in an array and then build the continous curve. I do not have the time by now, that'S all ... –  Dec 31 '10 at 10:00
  • That's still assuming enough resolution and what happens to (near-)intersections? Interesting idea though! – Pieter Dec 31 '10 at 10:30
  • 1
    @Pieter: no, not a question of the resulution. I need only a fist direction vector. As I wrote, it is in my brain, where verything works with light speed, but my fingers are very slow ... :-) –  Dec 31 '10 at 10:38
2

the same with a simple function in parameter notation:

\documentclass{article}
\usepackage{pst-func}
\begin{document}

\begin{pspicture*}(-3,-3)(3,3)
  \psaxes[linewidth=0.25pt,
   xlabelPos=top,
   labelFontSize=\scriptscriptstyle,
   labelsep=2pt,
   ticksize=0.05]{<->}(0,0)(-2,-1.75)(2,2)[$x$,0][$y$,90]
\pscustom[fillstyle=solid,fillcolor=red,opacity=0.4,
    linecolor=red,linewidth=1pt,algebraic]{%
  \psparametricplot{0}{2.5 .25 exp}{t^2  | 0.8*(sqrt(2.5-t^4)+t)}
  \psparametricplot{2.5 .25 exp}{0}{t^2  | 0.8*(-sqrt(2.5-t^4)+t)}
  \psparametricplot{0}{2.5 .25 exp}{-t^2 | 0.8*(-sqrt(2.5-t^4)+t)}
  \psparametricplot{2.5 .25 exp}{0}{-t^2 | 0.8*(sqrt(2.5-t^4)+t)}
}
\end{pspicture*}

\end{document}

alt text

  • thank for this additional answer. I get a new knowledge here, especially the notation {expr1|expr2}. – Display Name Dec 31 '10 at 09:24
  • 1
    code is now simplified. –  Dec 31 '10 at 09:31
  • I just want to inform that there is a simpler polar expression that produces "almost" identical graph. Here it is \def\x(#1){sin(#1)^3} \def\y(#1){(13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t))/16}, I stole it from this answer. – kiss my armpit Aug 23 '12 at 06:32
  • 1
    the so called heart curves are all listed here: http://mathworld.wolfram.com/HeartCurve.html –  Aug 23 '12 at 07:27
1

Still version:

Simplifying the existing answers.

enter image description here

\documentclass[border=12pt,pstricks]{standalone}
\usepackage{pst-plot}

\def\x(#1){sin(#1)^3}
\def\y(#1){(13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t))/16}

\psset{algebraic,plotpoints=100}

\begin{document}

\begin{pspicture}[showgrid=bottom](-2,-2)(2,2)
    \psparametricplot[origin={0,0.15}]{0}{\psPiTwo}{\x(t)|\y(t)}
\end{pspicture}

\end{document}

Animated version:

enter image description here

\documentclass[border=12pt,pstricks]{standalone}
\usepackage{pst-plot}
\usepackage[nomessages]{fp}
\FPeval\Delta{round(2*pi/30:2)}

\def\x(#1){sin(#1)^3}
\def\y(#1){(13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t))/16}

\psset{algebraic,plotpoints=100}

\begin{document}
\multido{\n=0.00+\Delta}{31}{%
\begin{pspicture}[showgrid=false](-1.5,-1.5)(1.5,1.5)
    \psparametricplot[origin={0,0.15},linecolor=red]{0}{\n}{\x(t)|\y(t)}
\end{pspicture}}

\end{document}