LaTeX forum ⇒ Graphics, Figures & Tablespgfplots | Cosecant Function Graph Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
sachinrajsharma
Posts: 35
Joined: Sun Apr 08, 2012 5:48 am

pgfplots | Cosecant Function Graph

Postby sachinrajsharma » Sat Nov 24, 2012 3:46 pm

Hi,

I am facing trouble in output of this code for a plot.
  1. \documentclass[10pt,a4paper]{article}
  2. \usepackage{tikz}
  3. \usepackage{pgfplots}
  4.  
  5. \begin{document}
  6. \begin{tikzpicture}
  7. \begin{axis}[
  8. xmin=-6,xmax=6,
  9. ymin=-2,ymax=2,
  10. axis x line=middle,
  11. axis y line=middle,
  12. axis line style=<->,
  13. xlabel={$x$},
  14. ylabel={$y$},
  15. ]
  16. \addplot[no marks,blue,<->] expression[samples=100]{cosec(deg(x} node[pos=3.0,anchor=south east]{$y=\cosec(x)$};
  17. \end{axis}
  18. \end{tikzpicture}
  19. \end{document}

I get an error.
  1. ! Undefined control sequence.

Please help in rectifying this issue.


Regards,
Sachin Sharma

Tags:

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Sat Nov 24, 2012 4:05 pm

There are two mistakes in your code.

  1. Two parentheses are missing in the actual plot command.
  2. The \cosec command does not exist. But \csc does.

The corrected example.
  1. \documentclass[11pt]{standalone}
  2. \usepackage{pgfplots}
  3.  
  4. \begin{document}
  5. \begin{tikzpicture}
  6. \begin{axis}[
  7. xmin=-6,
  8. xmax=6,
  9. xlabel={$x$},
  10. ymin=-2,
  11. ymax=2,
  12. ylabel={$y$},
  13. axis x line=middle,
  14. axis y line=middle,
  15. axis line style=<->
  16. ]
  17. \addplot[no marks,blue,<->] expression[samples=100]{cosec(deg(x))};
  18. \addlegendentry{$y=\csc(x)$};
  19. \end{axis}
  20. \end{tikzpicture}
  21. \end{document}



Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

sachinrajsharma
Posts: 35
Joined: Sun Apr 08, 2012 5:48 am

Postby sachinrajsharma » Sat Nov 24, 2012 5:49 pm

Thanks a lot....its great...

Sachin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 5 guests