[LaTeX] Tikz 平面绘图

目录

抬头部分调包

latex 复制代码
\usepackage{tikz}

直角坐标系函数

latex 复制代码
\begin{figure}[!hbtp]
\centering
\begin{tikzpicture}
\draw[->](-5,0)--(5,0)node[below]{$x$}; % 横轴
\draw[->](0,-5)--(0,5)node[right]{$y$}; % 纵轴
\draw[dashed](-4,-4) grid (4,4); % 平面网格
\draw[green,line width=2](-4,4)[domain=-4:4] plot({\x},{\x*\x/2-4})--(4,4)node[below right, black]{$y=\frac{1}{2}x^2-4$};   %  绘制二次曲线,起点,定义域,函数解析式,终点
\end{tikzpicture}
\caption{Quadratic function}
\label{fig:1}
\end{figure}
Figure \ref{fig:1} draws the graph of $y=\frac{1}{2}x^2-4$.

效果

直角坐标系参数方程

latex 复制代码
\begin{figure}[!hbtp]
\centering
\begin{tikzpicture}
\draw[->](-5,0)--(5,0)node[below]{$x$}; % 横轴
\draw[->](0,-5)--(0,5)node[right]{$y$}; % 纵轴
\draw[dashed](-4,-4) grid (4,4); % 平面网格
\fill[green!60!blue,opacity=90](0,2)[domain=0:360] plot({cos(\x)*2},{sin(\x)})--(0,2)node[below right, black]{$(2\cos(t),\sin(t))$};   % 绘制椭圆填充,起点,定义域,函数解析式,终点
\end{tikzpicture}
\caption{Quadratic function}
\label{fig:1}
\end{figure}
Figure \ref{fig:1} draws the graph of 
$\left\{ 
\begin{array}{l l} x=&2\cos(t) \\ y=&\sin(t)
\end{array}
\right.$

极坐标系

latex 复制代码
\begin{figure}[!hbtp]
\centering
\begin{tikzpicture}
\foreach \r in {1,2,3} \draw[dashed] (0,0) circle (\r); % 同心圆
\foreach \a in {0,30,...,330} \draw[dashed] (0,0) -- (\a:3); % 放射线
\filldraw[draw=red,fill=red!10,opacity=90,line width=2](0:1)[domain=0:360] plot({\x}:{1-sin(\x)})--(360:1)node[below=-40,]{$r=1-\sin(t)$};   % 绘制二次心形线的曲线与填充,起点,
\end{tikzpicture}
\end{figure}
Figure \ref{fig:1} draws the graph of $r=1-\sin(t)$.

效果

韦恩图

latex 复制代码
\begin{figure}[!hbtp]
\centering
\begin{tikzpicture}
    % 定义三个圆
    \def\circleA{(0,0) circle (1.5cm)}
    \def\circleB{(2,0) circle (1.5cm)}
    \def\circleC{(1,1.5) circle (1.5cm)}

    % 填充三个圆的公共交集(中心区域)
    \begin{scope}
        \clip \circleA;
        \clip \circleB;
        \fill[red!30] \circleC; % 红色半透明
    \end{scope}

    % 填充两两交集区域(示例:A和B的交集)
    \begin{scope}
        \clip \circleA;
        \fill[blue!20] \circleB; % 先填充A和B的交集
        \fill[white] \circleC;   % 然后用白色"挖掉"C覆盖的部分
    \end{scope}

    % 绘制圆的边框和标签
    \draw[thick] \circleA node[left] {$A$};
    \draw[thick] \circleB node[right] {$B$};
    \draw[thick] \circleC node[above] {$C$};

    % 可选:为不同区域添加文本标签
    \node at (1,- 2.5) {$A \cap B \cap \complement_{\Omega} C$};
\end{tikzpicture}
\end{figure}

完整代码

latex 复制代码
\documentclass{article}
\usepackage{tikz}

\begin{document}


\begin{figure}[!hbtp]
\centering
\begin{tikzpicture}
\draw[->](-5,0)--(5,0)node[below]{$x$}; % 横轴
\draw[->](0,-5)--(0,5)node[right]{$y$}; % 纵轴
\draw[dashed](-4,-4) grid (4,4); % 平面网格
\draw[green,line width=2](-4,4)[domain=-4:4] plot({\x},{\x*\x/2-4})--(4,4)node[below right, black]{$y=\frac{1}{2}x^2-4$};   % 绘制二次曲线,起点,定义域,函数解析式,终点
\end{tikzpicture}
\caption{Quadratic function}
\label{fig:1}
\end{figure}
Figure \ref{fig:1} draws the graph of $y=\frac{1}{2}x^2-4$.

\newpage
\begin{figure}[!hbtp]
\centering
\begin{tikzpicture}
\draw[->](-5,0)--(5,0)node[below]{$x$}; % 横轴
\draw[->](0,-5)--(0,5)node[right]{$y$}; % 纵轴
\draw[dashed](-4,-4) grid (4,4); % 平面网格
\fill[green!60!blue,opacity=90](0,2)[domain=0:360] plot({cos(\x)*2},{sin(\x)})--(0,2)node[below right, black]{$(2\cos(t),\sin(t))$};   % 绘制二次曲线,起点,定义域,函数解析式,终点
\end{tikzpicture}
\caption{Quadratic function}
\label{fig:1}
\end{figure}
Figure \ref{fig:1} draws the graph of 
$\left\{ 
\begin{array}{l l} x=&2\cos(t) \\ y=&\sin(t)
\end{array}
\right.$

\newpage
\begin{figure}[!hbtp]
\centering
\begin{tikzpicture}
\foreach \r in {1,2,3} \draw[dashed] (0,0) circle (\r); % 同心圆
\foreach \a in {0,30,...,330} \draw[dashed] (0,0) -- (\a:3); % 放射线
\filldraw[draw=red,fill=red!10,opacity=90,line width=2](0:1)[domain=0:360] plot({\x}:{1-sin(\x)})--(360:1)node[below=-40,]{$r=1-\sin(t)$};   % 绘制二次曲线,起点,
\end{tikzpicture}
\end{figure}
Figure \ref{fig:1} draws the graph of $r=1-\sin(t)$.


\begin{figure}[!hbtp]
\centering
\begin{tikzpicture}
    % 定义三个圆
    \def\circleA{(0,0) circle (1.5cm)}
    \def\circleB{(2,0) circle (1.5cm)}
    \def\circleC{(1,1.5) circle (1.5cm)}

    % 填充三个圆的公共交集(中心区域)
    \begin{scope}
        \clip \circleA;
        \clip \circleB;
        \fill[red!30] \circleC; % 红色半透明
    \end{scope}

    % 填充两两交集区域(示例:A和B的交集)
    \begin{scope}
        \clip \circleA;
        \fill[blue!20] \circleB; % 先填充A和B的交集
        \fill[white] \circleC;   % 然后用白色"挖掉"C覆盖的部分
    \end{scope}

    % 绘制圆的边框和标签
    \draw[thick] \circleA node[left] {$A$};
    \draw[thick] \circleB node[right] {$B$};
    \draw[thick] \circleC node[above] {$C$};

    % 可选:为不同区域添加文本标签
    \node at (1,- 2.5) {$A \cap B \cap \complement_{\Omega} C$};
\end{tikzpicture}
\end{figure}
\end{document} 
相关推荐
李游Leo1 天前
【共创稿事节】 HarmonyOS 7 空间化 UI 实战:从平面布局到空间层级的界面重构
ui·平面·harmonyos
意图共鸣1 天前
意图共鸣科技《智能体接口化白皮书2.0》从三脚架到四面体——三角模型不是平面的,是立体的
科技·平面
算法大模型备案干货咪1 天前
《敏感词库工程实现:从平面词表到分层拦截系统》
平面
我爱cope3 天前
【计算机网络 | 网络层12:SDN:控制平面与数据平面分离意味着什么?】
网络·学习·计算机网络·平面
陈天伟教授8 天前
【30天学会机械制图 第13 天】项目三 从复杂立体到简单立体,再到平面图形 任务2 认识截交线和相贯线
平面·工程制图·机械制图
奈斯先生Vector8 天前
从“能调用”到“可替换”:Coze 多模型 API 编排层设计指南
linux·运维·人工智能·ubuntu·平面·ios
制造业的搬运工8 天前
PCB电源完整性设计:去耦电容·电源平面·地分割
科技·平面·制造·pcb工艺
陈天伟教授9 天前
【30天学会机械制图 第14 天】项目三 从复杂立体到简单立体,再到平面图形 任务3 从图纸认识组合体
平面
奈斯先生Vector10 天前
当 Agent 配置变成控制平面:从 RelayRouter 的网关思路重新理解 DeepSeek Harness
平面
陈天伟教授12 天前
【30天学会机械制图 第11 天】项目二 简单的立体变成平面图形 任务3 认识曲面立体的三视图
平面·信息可视化·工程制图·机械制图·工程制图,机械制图