2d-x-square-with-circle.tex 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. \documentclass[varwidth=true, border=2pt]{standalone}
  2. \usepackage{pgfplots}
  3. \usepackage{tikz}
  4. \begin{document}
  5. \begin{tikzpicture}
  6. \begin{axis}[
  7. legend pos=south west,
  8. axis x line=middle,
  9. axis y line=middle,
  10. grid = major,
  11. %width=9cm,
  12. %height=9cm,
  13. grid style={dashed, gray!30},
  14. xmin=-1.5, % start the diagram at this x-coordinate
  15. xmax= 1.5, % end the diagram at this x-coordinate
  16. %ymin=-0.25, % start the diagram at this y-coordinate
  17. %ymax= 2.25, % end the diagram at this y-coordinate
  18. axis background/.style={fill=white},
  19. xlabel=$x$,
  20. ylabel=$y$,
  21. %xticklabels={-2,-1.6,...,7},
  22. %yticklabels={-8,-7,...,8},
  23. tick align=outside,
  24. minor tick num=-3,
  25. enlargelimits=true,
  26. tension=0.08]
  27. \addplot[domain=-1.5:1.5, red, thick,samples=50] {x*x};
  28. \draw[blue, thick] \pgfextra{
  29. \pgfpathellipse{\pgfplotspointaxisxy{0}{1}}
  30. {\pgfplotspointaxisdirectionxy{0.87}{0}}
  31. {\pgfplotspointaxisdirectionxy{0}{0.87}}
  32. % see also the documentation of
  33. % 'axis direction cs' which
  34. % allows a simpler way to draw this ellipse
  35. };
  36. \end{axis}
  37. \end{tikzpicture}
  38. \end{document}