1

I have never used LaTeX for anything similar to this and do not know where to begin with this. Can someone please help me by showing how to draw the following figure?

enter image description here

  • Please add a minimal working example (MWE) of what you've tried so far, at least the math formula of the curve. – CarLaTeX Jan 17 '18 at 7:47
  • @CarLaTeX Sorry, the formula is $y^2 = x^2(x+1)$. Unfortunately, I don't have a MWE, or I would have included it. As I said, this is all very new to me. – Mark Jan 17 '18 at 7:55
1

By far the best in-LaTeX graphics package is pstricks. https://ctan.org/pkg/pstricks?lang=en The following does that curve, plus axes, some dots, and some text.

\documentclass{article}
\usepackage[dvips]{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{pst-plot}
\usepackage{pstricks}
\usepackage{multido}
\usepackage{fp}
\usepackage{ifthen}

\begin{document}

\psset{unit=12mm, xunit=12mm, yunit=12mm}
\pspicture*(-2,-2)(2,2)     % Star form clips anything beyond boundaries
\psset{linewidth=0.17mm,linecolor=black}
\psline{->}(-2,0)(2,0)
\rput[rb](2,0.1){$x$}
\psline{->}(0,-2)(0,2)
\rput[lt](0.1,2){$y$}
\psset{linewidth=0.4mm,linecolor=green}
% In following, parameter  t  goes from  -1.6  to  1.6 .
% Must use t for parameter.
% Functions are            x = t^2 - 1     y = t^3 - t .
\parametricplot{-1.6}{1.6}{t 2 exp 1 sub   t 3 exp t sub}
\psset{linecolor=blue}
\pscircle*(-1,-1){0.6mm}
\rput[rt](-1.1,-1.1){$(-1,0)$}
\pscircle(1,1.414){2mm}
\rput[l](1.2,1.414){$(1,\sqrt{2}\;)$}
\psset{linewidth=0.23mm,linecolor=red,linestyle=dashed}
% Following plots  sin(50 x)  (sin expects degrees).
% Must use x for argument.  x goes from  -2  to  2 .
\psplot[plotpoints=200]{-2}{2}{x 500 mul sin}
\rput[b](-1,1.2){function plots}
\endpspicture

\end{document}
  • Hi. Thank you for answering. Can you help me out a little, I can't compile since I'm getting the error: ! Undefined control sequence. \c@lor@to@ps ...name c@lor@ps@#1\endcsname #2 \@@ l.17 \psline{->} (-2,0)(2,0) – Mark Jan 18 '18 at 5:27
  • I don't know what system you're using, but pstricks needs the dvips processor. So you have to do latex followed by dvips. Convert the ps file to pdf later if you wish. You can't for example use pdflatex. Better not to anyway. – cwhctza Jan 18 '18 at 6:24
  • Yes, I was just reading about that. I was able to run your code using xelatex, and then make my changes. I'll need to learn, however, how to run this code in my own work since I can't directly run it in pdflatex. I suppose there is a method to include it the same was as one would include an eps. – Mark Jan 18 '18 at 6:29
  • For me pstricks is so good, I won't consider pdflatex. Much better to have all your code in one file. Personal choice of course. If you've invested a lot of time in documents that depend strongly on pdflatex, you'd obviously be reluctant to change. I don't like that we have all these options diverging away, instead of a set of interoperable packages. – cwhctza Jan 18 '18 at 7:33
1

Starting point:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
  \draw[thin] (-5,0)--(5,0);% x axis
  \draw[thin] (0,-5)--(0,5);%y axis
    \draw[fill=blue,opacity=0.3] (2,5) circle (3pt);% circle by center and radius
  \node[anchor=west,yshift=10pt] at (2,5){test text};% text rigth of a given point
  \draw[fill=gray!30,black] (-2,4) circle (7pt) coordinate (A);%coordinate saves a point position in a name inside ()
  \node[text width=4cm,anchor=west,xshift=10pt] at (A) {test text here that will break where needed};%Then we can use saved point as it was coordinates
  \draw[ultra thick] (4,5) to[out=230,in=0](0,-1) to[out=180,in=270] (-1,0) to[out=90,in=180] (0,1) to[out=0,in=140](4,-5);% From a point goes to another using these rules:
  % (imagine an analog clock: 3 o'clock=0 degrees 9 o'clock-180 degrees 12 =90 degrees )
  %Then: "in" is the angle in which the line uses to get in the final point.
  %"out" is the angle which the line uses to get out of the starting point.
  %The above angles in respect to our more above watch angles.
\end{tikzpicture}
\end{document}

Compile... Play until you are close to what you want... and I or someone will help more after a MWE: (This with your modifications to be as close to yours as you can)... The last command is just a way for curves... You need a plot command...

(Just added to give a starting point with tikz)

  • I will delete the answer after. I know it is not a real answer but could not write all these as a comment – koleygr Jan 17 '18 at 8:05
  • Thank you. I will try to make this more like in the pic, and ask you if there were problems. – Mark Jan 17 '18 at 8:13
  • I don't think this solution is really optimal since I think manually trying to fix the shape of the curve is going to take too much time and never look exactly right. I wonder if there is a better approach where the curve gets drawn automatically when I input the function. I'd be better off just inserting the jpeg image into my code. – Mark Jan 17 '18 at 8:19
  • My last sentences are about this... This is just a minimal example of how we use tikz... You have to show some effort to get help and these commands are the best start but not the solution. You will use plot for the curve and for the axis... But you will need all the rest for any tikz drawing.... Just copy the line in your example... But place some points and some text around... You have to learn the basic tikz commands and then learn to draw functions... This is because you need to place text next to points... This is the easy way and by learning these you will make a big step without manual – koleygr Jan 17 '18 at 8:28
  • Sorry, I think I skipped the last comments in your answer. Thank you for your help. – Mark Jan 17 '18 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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