在LaTeX中绘制截断的线性方程

时间:2015-04-24 11:38:40

标签: graph latex tikz

我正在写我的硕士论文,我想在LaTeX中创建下图: Truncated linear equation

这是我的代码,直到现在:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\usepackage{pgfplots}
\usepackage[active,float]{preview}

\PreviewEnvironment{tikzpicture}

\begin{document}

\begin{tikzpicture}[scale=1.5]
    %axis
    \draw (0,0) -- coordinate (x axis mid) (4,0);
        \draw (0,0) -- coordinate (y axis mid) (0,3);

        \foreach \x in {0,...,2}
        \draw (\x,0pt) -- (\x,-3pt)     node[anchor=north] {\x};
        \foreach \y in {0,...,1}
            \draw (0pt,\y) -- (-3pt,\y)     node[anchor=east] {$\gamma_{max}$}; 

    % draw lines
    \draw [blue,thick](0,0) coordinate (a_1) -- (2,1) coordinate (a_2); 
    \draw [blue,thick](2,1) coordinate (b_1) -- (3,1) coordinate (b_2); 

    \draw[black,dotted,thick] (a_2|-o) -- (b_1);
    %labels      
    \node [below=0.6cm] at (x axis mid) {\textbf{N$_i$(x$_c$)$\;\;\longrightarrow$}};
    \node [left=0.5cm] at (y axis mid) {$f_1$(x$_c$)};
\end{tikzpicture}

\end{document}

我的问题如下:

  • 无法像他们那样创建系统的来源,
  • 无法向北方向放置箭头,
  • 无法正确缩放轴,
  • 无法以正确的方式放置$Q_2$

1 个答案:

答案 0 :(得分:0)

此源代码

\documentclass[tikz,multi=false,border=2mm]{standalone}

\begin{document}

\begin{tikzpicture}[scale=1.5]
    %axes
    \draw (0,0) -- (3.5,0);
    \draw (0,0) -- (0,2);
    \foreach \x in {0,2} \draw (\x,0pt) -- (\x,-3pt);
    \foreach \y in {.5,1.5} \draw (0pt,\y) -- (-3pt,\y);
    % draw lines
    \draw [blue,thick] (0,.5) -- (2,1.5) -- (3,1.5);
    \draw [black,dotted,thick] (2,1.5) -- (2,0);
    %labels
    \node at (0,-.25) {$0$};  %%  default
    \node at (2,-.25) {$\mathsf{Q}_2$};
    \node [below=6mm] at (2,0) {$\mathsf{N_i(x_c)}\;\;\longrightarrow$};
    \node at (-.25,.5) {$\mathsf{0}$};  %%  sans serif
    \node at (-.4,1.5) {$\gamma_{max}$};
    \node at (-1,1.1) {$\uparrow$};
    \node at (-1,.8) {$\mathsf{f_1(x_c)}$};
\end{tikzpicture}

\end{document}

产生以下输出:

screenshot of output pdf

即使我在第23和24行的y轴标签解决方案可能非常粗糙。

另外,我认为数学模式中的serif和sans serif字体的管理可以比我更有条理的方式进行:我的代码中可以改进一些东西,但我认为你有使用的技能甚至只是它的一些部分。

最后,如果您愿意,可以使用very thick选项(而不仅仅是thick)绘制蓝线。