Created
August 20, 2019 13:04
-
-
Save OceanS2000/4b82a0c2797838c1f21c8895767ee597 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{standalone} | |
\usepackage{tikz} | |
\tikzstyle{reverseclip}=[insert path={(current page.north east) -- | |
(current page.south east) -- | |
(current page.south west) -- | |
(current page.north west) -- | |
(current page.north east)} | |
] | |
\begin{document} | |
\begin{tikzpicture} | |
\draw[orange,domain=0:4,samples=100] plot(\x, {-\x*\x+4*\x}); | |
% 将文字结点保存起来,绘制网格时clip掉 | |
\draw (2, 4) node (text) {$f(x)$}; | |
\begin{scope}[even odd rule] | |
\begin{pgfinterruptboundingbox} | |
% 防止插入的大路径影响图片大小 | |
\path[clip] (text.south west) |- (text.north east) |- cycle [reverseclip]; | |
\end{pgfinterruptboundingbox} | |
\draw[gray,very thin] (0, 0) grid (6, 6); | |
\end{scope} | |
\draw[->] (0, 0) node[left] {$O$} -- (6, 0) node[anchor=north] {$x$}; | |
\draw[->] (0, 0) -- (0, 6) node[anchor=east] {$y$}; | |
\end{tikzpicture} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment